public ActionResult DeleteCandidate(string id) { if (!user.IsManager()) { return(View("Error")); } int id_cand = Convert.ToInt32(id); TestCandidateList check = db.TestCandidateLists.FirstOrDefault(c => c.CandidateID == id_cand); if (check != null) { TempData["CandidateID"] = false; TempData["statusCAN"] = "This candidate has taken the test"; return(RedirectToAction("Candidate")); } bool del = managerDal.DeleteCandidate(id_cand); if (del) { TempData["CandidateID"] = true; TempData["statusCAN"] = "Delete successful"; } else { TempData["CandidateID"] = false; TempData["statusCAN"] = "Delete failed"; } return(RedirectToAction("Candidate")); }