public ActionResult Delete(int id) { try { _petsRepo.Delete(id); return(View("Index")); } catch { return(HttpNotFound()); } }
public ActionResult Delete(int id) { PetsRepository repo = new PetsRepository(); Pet item = repo.GetById(id); if (AuthenticationManager.LoggedUser.Id != 1 && AuthenticationManager.LoggedUser.Id != item.UserId) { RedirectToAction("Login", "Home"); } else { repo.Delete(item); } return(RedirectToAction("Index", "Pet")); }