public ActionResult Delete(int id)
        {
            var petRepo = new PetRepository();

            petRepo.Delete(id);
            return(RedirectToAction("Index"));
        }
Exemple #2
0
 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));
     }
 }
Exemple #3
0
 public void Delete(int id)
 {
     Repo.Delete(id);
 }
Exemple #4
0
        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"));
 }