Пример #1
0
 public ActionResult Delete(int id)
 {
     try
     {
         _petsRepo.Delete(id);
         return(View("Index"));
     }
     catch
     {
         return(HttpNotFound());
     }
 }
Пример #2
0
        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"));
        }