public ActionResult Delete(int id) { var petRepo = new PetRepository(); petRepo.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Delete(Guid id, FormCollection collection) { try { repository.Delete(id); repository.Save(); return(RedirectToAction("Index")); } catch (Exception e) { int errorCode; if (int.TryParse(e.Message, out errorCode) && errorCode == (int)DbError.ConstraintCheckViolation) { ModelState.AddModelError("", "This pet have registered appointments. You have to cancel related appointments in order to delete it!"); } else { ModelState.AddModelError("", e.Message); } Pet pet = repository.GetById(id); return(View("Delete", pet)); } }
public void Delete(int id) { Repo.Delete(id); }
public static void DeletePet(PetData pet) { PetRepository petRep = new PetRepository(); petRep.Delete(pet.Id); }
public ActionResult Delete(int id) { repoPet.Delete(id); return(RedirectToAction("Index")); }
public ActionResult Delete(Pet pet) { petRepo.Delete(pet); return(RedirectToAction("Index")); }