D
D
Dmitry2016-07-25 19:42:24
ASP.NET
Dmitry, 2016-07-25 19:42:24

How to notify the user that he added something?

Hello! For example, a user adds a new article to the site, how to show the user that his article has been added?
for example there is a method

public void AddArticle(Guid userId, string articleText)
{
  Db.Article.Add(new Article...);
  Db.SaveChanges();
}

What do you think, is it possible to return the identifier of a new record from the AddArticle method, or is it possible to return some kind of object, say Result, which has the fields Result, Message, Error? Tell who uses what in this situation

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kovalsky, 2016-07-25
@dmitryKovalskiy

depends on what you want to do with the results. Based on the fact that there were no unscheduled exceptions, you can consider that the code worked correctly and the entry was added. In your case, SaveChanges returns the number of rows that were manipulated. If something more than 0 is returned, then the line has been added.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question