public ActionResult Delete(int id) { try { PageContent objPageContent = _repPageContent.GetSingle(x => x.Id == id); _repPageContent.Delete(objPageContent); _repPageContent.Save(); TempData[LeonniConstants.SuccessMessage] = "Page Content Deleted Successfully"; } catch { TempData[LeonniConstants.ErrorMessage] = "Cannot be deleted, PageContent is being Used"; } return(RedirectToAction("Index")); }