Asp.Net MVC 5 Restriction -
I want to create a simple message system. There are three important pillars in the message table;
Message ID
Sender's User ID
Username
I am getting the message ID from the URL and it has been ascertained whether the logged-in user is the sender or the receiver of that message. If not, I do not want to see the message.
Public Action Detail Details (int? Id) {var result = db.Talep.Where (e => e.id = ID & amp; (user ID == User.Identity.GetUserId (). ToString () || E. Receiver == User.Identity.Name)); If (result == zero) {return HttpNotFound (); } Telep Telepp = DB. Talep.Find (ID); See the return (story); }
The forwardword code is not working, the result
never becomes zero even if the statement is wrong I tried to use the . Any
extension but this does not work I hope someone can help you.
. Always return where and IEnumerable, which will never be empty.
There are 2 ways to handle it:
-
If you change this thing: if (Anyone's result! Anyone will check whether the return Any item in the list - If there are no items, you will return your error.
-
To change your LINQ query to use FirstOrDefault (), it will return the first item to your request, or zero if no items are found.
There is no side except ... If you use FirstOurfault (), after checking the if statement for zero, Nearby is a telepo, so the last call to see the story by id will be useless. Just look back (results)
Comments
Post a Comment