public ActionResult DeleteConfirmed(int id) { try { if (ModelState.IsValid) { empRepository.DeleteRecord(id); empRepository.SaveRecord(); } } catch (DataException) { ModelState.AddModelError("", "Unable to delete the record."); } return(RedirectToAction("Index")); }