krasipetrovbg

Untitled

Jan 27th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. public ActionResult Delete(int? articleId, int? estimateId)
  2. {
  3.     if(articleId == null || estimateId == null)
  4.     {
  5.         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
  6.     }
  7.     Enroll enroll = db.Enrolls.Find(estimateId, articleId);
  8.     if(enroll == null)
  9.     {
  10.         TempData["message"] = "Оценката не е намерена! Моля, опитайтено отново!";
  11.         return RedirectToAction("NotFound", "Home");
  12.     }
  13.  
  14.     db.Enrolls.Remove(enroll);
  15.     db.SaveChanges();
  16.  
  17.     return RedirectToAction("Index", "Enrolls");
  18. }
Add Comment
Please, Sign In to add comment