Beispiel #1
0
        public ActionResult View(int id)
        {
            PolicyMessageGroupItemCar policyMessageGroupItemCar = new PolicyMessageGroupItemCar();

            policyMessageGroupItemCar = policyMessageGroupItemCarRepository.GetPolicyMessageGroupItemCar(id);;

            //Check Exists
            if (policyMessageGroupItemCar == null)
            {
                ViewData["ActionMethod"] = "ViewGet";
                return(View("RecordDoesNotExistError"));
            }

            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyMessageGroupItemCar.PolicyGroupId);

            PolicyMessageGroupItemCarVM policyMessageGroupItemCarVM = new PolicyMessageGroupItemCarVM();

            policyMessageGroupItemCarVM.PolicyGroupName           = policyGroup.PolicyGroupName;
            policyMessageGroupItemCarVM.PolicyGroupId             = policyGroup.PolicyGroupId;
            policyMessageGroupItemCarVM.PolicyMessageGroupItemCar = policyMessageGroupItemCar;

            return(View(policyMessageGroupItemCarVM));
        }
Beispiel #2
0
        public ActionResult Delete(int id)
        {
            PolicyMessageGroupItemCar policyMessageGroupItemCar = new PolicyMessageGroupItemCar();

            policyMessageGroupItemCar = policyMessageGroupItemCarRepository.GetPolicyMessageGroupItemCar(id);;

            //Check Exists
            if (policyMessageGroupItemCar == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyMessageGroupItemCar.PolicyGroupId);

            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroupMessages(policyGroup.PolicyGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            PolicyMessageGroupItemCarVM policyMessageGroupItemCarVM = new PolicyMessageGroupItemCarVM();

            policyMessageGroupItemCarVM.PolicyGroupName           = policyGroup.PolicyGroupName;
            policyMessageGroupItemCarVM.PolicyGroupId             = policyGroup.PolicyGroupId;
            policyMessageGroupItemCarVM.PolicyMessageGroupItemCar = policyMessageGroupItemCar;

            return(View(policyMessageGroupItemCarVM));
        }
Beispiel #3
0
        public ActionResult Create(PolicyMessageGroupItemCarVM policyMessageGroupItemCarVM)
        {
            int policyGroupId = policyMessageGroupItemCarVM.PolicyMessageGroupItemCar.PolicyGroupId;

            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyGroupId);;

            //Check Exists
            if (policyGroup == null)
            {
                ViewData["ActionMethod"] = "CreatePost";
                return(View("RecordDoesNotExistError"));
            }

            //Check AccessRights
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroupMessages(policyGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            //Update Model from Form
            try
            {
                UpdateModel <PolicyMessageGroupItemCar>(policyMessageGroupItemCarVM.PolicyMessageGroupItemCar, "PolicyMessageGroupItemCar");
            }
            catch
            {
                string n = "";
                foreach (ModelState modelState in ViewData.ModelState.Values)
                {
                    foreach (ModelError error in modelState.Errors)
                    {
                        n += error.ErrorMessage;
                    }
                }
                ViewData["Message"] = "ValidationError : " + n;
                return(View("Error"));
            }
            try
            {
                policyMessageGroupItemCarRepository.Add(policyMessageGroupItemCarVM.PolicyMessageGroupItemCar);
            }
            catch (SqlException ex)
            {
                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", "PolicyMessageGroupItem", new { id = policyGroupId }));
        }
Beispiel #4
0
        public ActionResult Create(int id)
        {
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(id);;

            //Check Exists
            if (policyGroup == null)
            {
                ViewData["ActionMethod"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }

            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroupMessages(id))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            PolicyMessageGroupItemCarVM policyMessageGroupItemCarVM = new PolicyMessageGroupItemCarVM();

            policyMessageGroupItemCarVM.PolicyGroupName = policyGroup.PolicyGroupName;
            policyMessageGroupItemCarVM.PolicyGroupId   = policyGroup.PolicyGroupId;

            PolicyMessageGroupItemCar policyMessageGroupItemCar = new PolicyMessageGroupItemCar();

            policyMessageGroupItemCar.ProductId     = 3; //Car
            policyMessageGroupItemCar.PolicyGroupId = policyGroup.PolicyGroupId;
            policyMessageGroupItemCarVM.PolicyMessageGroupItemCar = policyMessageGroupItemCar;

            //Populate List of PolicyLocations
            PolicyLocationRepository policyLocationRepository = new PolicyLocationRepository();
            SelectList policyLocations = new SelectList(policyLocationRepository.GetAllPolicyLocations().ToList(), "PolicyLocationId", "PolicyLocationName");

            policyMessageGroupItemCarVM.PolicyLocations = policyLocations;

            return(View(policyMessageGroupItemCarVM));
        }