public ActionResult Delete(int id) { var category = _repository.Find(c => c.Id == id).FirstOrDefault(); _repository.Remove(category); return(RedirectToAction("ManageCategories")); }
public ActionResult Delete(int id) { var result = _repository.Find(n => n.Id == id); var news = result.FirstOrDefault(); _repository.Remove(news); return(RedirectToAction("Index")); }
public ActionResult Delete(int id) { var entity = _repository.Find(m => m.Id == id); var news = entity.FirstOrDefault(); if (news.UserId != User.Identity.GetUserId() && !User.IsInRole("Administrator")) { return(HttpNotFound()); } _repository.Remove(news); return(RedirectToAction("Show", "News", new { id = news.NewsId })); }