public ActionResult Delete(int id, IFormCollection collection) { try { _context.Remove(GetServiceContractById(id)); _context.SaveChanges(); return(RedirectToAction(nameof(List))); } catch { return(View()); } }
public ActionResult Delete(int id, IFormCollection collection) { try { var c = GetFullyLoadedCustomerById(id); if (c.ServiceContracts.Count() > 0) { return(View("_CantDeleteDueToContracts")); } _context.Remove(GetCustomerById(id)); _context.SaveChanges(); return(RedirectToAction(nameof(List))); } catch { return(View()); } }