public ActionResult Delete(int id) { Partner partner = new Partner(); partner = partnerRepository.GetPartner(id); //Check Exists if (partner == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } PartnerVM partnerVM = new PartnerVM(); partnerVM.AllowDelete = true; //Attached Items List <PartnerReference> partnerReferences = partnerRepository.GetPartnerReferences(partner.PartnerId); if (partnerReferences.Count > 0) { partnerVM.AllowDelete = false; partnerVM.PartnerReferences = partnerReferences; } partnerVM.Partner = partner; return(View(partnerVM)); }