public ActionResult Delete(PolicyCarOtherGroupItemDataTableItemVM policyCarOtherGroupItemDataTableItemVM)
        {
            //Check PolicyCarOtherGroupItemDataTableRow Exists
            PolicyCarOtherGroupItemDataTableRow policyCarOtherGroupItemDataTableRow = new PolicyCarOtherGroupItemDataTableRow();

            policyCarOtherGroupItemDataTableRow = policyCarOtherGroupItemDataTableRowRepository.GetPolicyCarOtherGroupItemDataTableRow(
                policyCarOtherGroupItemDataTableItemVM.PolicyCarOtherGroupItemDataTableRow.PolicyCarOtherGroupItemDataTableRowId
                );
            if (policyCarOtherGroupItemDataTableRow == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Check Policy Exists
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyCarOtherGroupItemDataTableItemVM.PolicyGroup.PolicyGroupId);
            if (policyGroup == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Check PolicyOtherGroupHeader Exists
            PolicyOtherGroupHeader policyOtherGroupHeader = new PolicyOtherGroupHeader();

            policyOtherGroupHeader = policyOtherGroupHeaderRepository.GetPolicyOtherGroupHeader(
                policyCarOtherGroupItemDataTableItemVM.PolicyOtherGroupHeader.PolicyOtherGroupHeaderId
                );
            if (policyOtherGroupHeader == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Delete Form Item
            try
            {
                policyCarOtherGroupItemDataTableItemRepository.Delete(policyCarOtherGroupItemDataTableRow);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicyCarOtherGroupItemDataTableItem.mvc/Delete/" + policyCarOtherGroupItemDataTableItemVM.PolicyCarOtherGroupItemDataTableRow.PolicyCarOtherGroupItemDataTableRowId;
                    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", new { id = policyCarOtherGroupItemDataTableItemVM.PolicyOtherGroupHeader.PolicyOtherGroupHeaderId, policyGroupId = policyCarOtherGroupItemDataTableItemVM.PolicyGroup.PolicyGroupId }));
        }
Exemplo n.º 2
0
        //Delete
        public void Delete(PolicyCarOtherGroupItemDataTableRow policyCarOtherGroupItemDataTableRow)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeletePolicyCarOtherGroupItemDataTableItem_v1(
                policyCarOtherGroupItemDataTableRow.PolicyCarOtherGroupItemDataTableRowId,
                adminUserGuid,
                policyCarOtherGroupItemDataTableRow.VersionNumber
                );
        }
        public ActionResult Delete(int id, int policyGroupId, int policyOtherGroupHeaderId)
        {
            PolicyCarOtherGroupItemDataTableItemVM policyCarOtherGroupItemDataTableItemVM = new PolicyCarOtherGroupItemDataTableItemVM();

            //Check PolicyCarOtherGroupItemDataTableRow Exists
            PolicyCarOtherGroupItemDataTableRow policyCarOtherGroupItemDataTableRow = new PolicyCarOtherGroupItemDataTableRow();

            policyCarOtherGroupItemDataTableRow = policyCarOtherGroupItemDataTableRowRepository.GetPolicyCarOtherGroupItemDataTableRow(id);
            if (policyCarOtherGroupItemDataTableRow == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check Policy Exists
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyGroupId);
            if (policyGroup == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check PolicyOtherGroupHeader Exists
            PolicyOtherGroupHeader policyOtherGroupHeader = new PolicyOtherGroupHeader();

            policyOtherGroupHeader = policyOtherGroupHeaderRepository.GetPolicyOtherGroupHeader(policyOtherGroupHeaderId);
            if (policyOtherGroupHeader == null)
            {
                ViewData["ActionMethod"] = "EditGet";
                return(View("RecordDoesNotExistError"));
            }

            policyCarOtherGroupItemDataTableItemVM.PolicyOtherGroupHeader = policyOtherGroupHeader;
            policyGroupRepository.EditGroupForDisplay(policyGroup);
            policyCarOtherGroupItemDataTableItemVM.PolicyGroup = policyGroup;

            policyCarOtherGroupItemDataTableItemVM.PolicyCarOtherGroupItemDataTableRow = policyCarOtherGroupItemDataTableRow;

            List <PolicyCarOtherGroupItemDataTableItem> policyCarOtherGroupItemDataTableItems = new List <PolicyCarOtherGroupItemDataTableItem>();

            policyCarOtherGroupItemDataTableItems = policyCarOtherGroupItemDataTableRowRepository.GetPolicyCarOtherGroupItemDataTableItems(id, policyOtherGroupHeaderId);
            if (policyCarOtherGroupItemDataTableItems != null)
            {
                policyCarOtherGroupItemDataTableItemVM.PolicyCarOtherGroupItemDataTableItems = policyCarOtherGroupItemDataTableItems;
            }

            return(View(policyCarOtherGroupItemDataTableItemVM));
        }
 public PolicyCarOtherGroupItemDataTableItemVM(
     PolicyCarOtherGroupItemDataTableRow policyCarOtherGroupItemDataTableRow,
     PolicyCarOtherGroupItem policyCarOtherGroupItem,
     PolicyOtherGroupHeader policyOtherGroupHeader,
     PolicyGroup policyGroup,
     List <PolicyCarOtherGroupItemDataTableItem> policyCarOtherGroupItemDataTableItems
     )
 {
     PolicyCarOtherGroupItemDataTableRow = policyCarOtherGroupItemDataTableRow;
     PolicyCarOtherGroupItem             = policyCarOtherGroupItem;
     PolicyOtherGroupHeader = policyOtherGroupHeader;
     PolicyGroup            = policyGroup;
     PolicyCarOtherGroupItemDataTableItems = policyCarOtherGroupItemDataTableItems;
 }