public ActionResult Delete(PartnerVM partnerVM, FormCollection collection) { //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Get Item From Database Partner partner = new Partner(); partner = partnerRepository.GetPartner(partnerVM.Partner.PartnerId); //Check Exists if (partner == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Delete Item try { partnerRepository.Delete(partnerVM); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/Partner.mvc/Delete/" + partner.PartnerId; return(View("VersionError")); } LogRepository logRepository = new LogRepository(); logRepository.LogError(ex.Message); ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details"; return(View("Error")); } return(RedirectToAction("List")); }