// GET: Course/Delete/5 public ActionResult Delete(int id) { try { bool resp = _icourse.DeletCourse(id); if (resp == false) { TempData["MessageError"] = "You can not delete a course already mapped to a student"; return(RedirectToAction(nameof(Index))); } TempData["Message"] = "Course was deleted successfully"; return(RedirectToAction(nameof(Index))); } catch (Exception e) { TempData["MessageError"] = e.Message.ToString(); return(RedirectToAction(nameof(Index))); } }