Esempio n. 1
0
        // GET: /View
        public ActionResult View(int id)
        {
            //Get PolicyAirCabinGroupItem
            PolicyAirCabinGroupItem policyAirCabinGroupItem = new PolicyAirCabinGroupItem();

            policyAirCabinGroupItem = policyAirCabinGroupItemRepository.GetPolicyAirCabinGroupItem(id);

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

            //populate new PolicyAirCabinGroupItem with known PolicyGroup Information
            policyAirCabinGroupItemRepository.EditItemForDisplay(policyAirCabinGroupItem);

            //Add the PolicyRouting information
            PolicyRouting policyRouting = new PolicyRouting();

            if (policyAirCabinGroupItem.PolicyRoutingId != null)
            {
                policyRouting = policyRoutingRepository.GetPolicyRouting((int)policyAirCabinGroupItem.PolicyRoutingId);
                policyRoutingRepository.EditForDisplay(policyRouting);
            }

            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyAirCabinGroupItem.PolicyGroupId);

            //Show Form
            PolicyAirCabinGroupItemViewModel policyAirCabinGroupItemViewModel = new PolicyAirCabinGroupItemViewModel(policyGroup, policyAirCabinGroupItem, policyRouting);

            return(View(policyAirCabinGroupItemViewModel));
        }
Esempio n. 2
0
        // GET: /CreatePolicyRouting
        public ActionResult CreatePolicyRouting(int id, int policyAirCabinGroupItemId)
        {
            //Get PolicyAirVendorGroupItem
            PolicyAirCabinGroupItem policyAirCabinGroupItem = new PolicyAirCabinGroupItem();

            policyAirCabinGroupItem = policyAirCabinGroupItemRepository.GetPolicyAirCabinGroupItem(policyAirCabinGroupItemId);

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

            //populate new PolicyAirVendorGroupItem with known PolicyGroup Information
            policyAirCabinGroupItemRepository.EditItemForDisplay(policyAirCabinGroupItem);

            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyAirCabinGroupItem.PolicyGroupId);

            PolicyRouting policyRouting = new PolicyRouting();
            PolicyAirCabinGroupItemViewModel policyAirCabinGroupItemViewModel = new PolicyAirCabinGroupItemViewModel(policyGroup, policyAirCabinGroupItem, policyRouting);

            //Show 'Create' Form
            return(View(policyAirCabinGroupItemViewModel));
        }
Esempio n. 3
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get PolicyAirCabinGroupItem
            PolicyAirCabinGroupItem policyAirCabinGroupItem = new PolicyAirCabinGroupItem();

            policyAirCabinGroupItem = policyAirCabinGroupItemRepository.GetPolicyAirCabinGroupItem(id);

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

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

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

            //Populate List of AirlineCabins
            AirlineCabinRepository airlineCabinRepository = new AirlineCabinRepository();
            SelectList             airlineCabins          = new SelectList(airlineCabinRepository.GetAllAirlineCabins().ToList(), "AirlineCabinCode", "AirlineCabinDefaultDescription");

            ViewData["AirlineCabinCodeList"] = airlineCabins;

            policyAirCabinGroupItemRepository.EditItemForDisplay(policyAirCabinGroupItem);
            PolicyGroup policyGroup = policyGroupRepository.GetGroup(policyAirCabinGroupItem.PolicyGroupId);


            //Add the PolicyRouting information
            PolicyRouting policyRouting = new PolicyRouting();

            if (policyAirCabinGroupItem.PolicyRoutingId != null)
            {
                policyRouting = policyRoutingRepository.GetPolicyRouting((int)policyAirCabinGroupItem.PolicyRoutingId);
                policyRoutingRepository.EditPolicyRouting(policyRouting);
            }

            //Show Edit Form
            PolicyAirCabinGroupItemViewModel policyAirCabinGroupItemViewModel = new PolicyAirCabinGroupItemViewModel(policyGroup, policyAirCabinGroupItem, policyRouting);

            return(View(policyAirCabinGroupItemViewModel));
        }
Esempio n. 4
0
        public ActionResult Create(PolicyAirCabinGroupItemViewModel policyAirCabinGroupItemViewModel, string btnSubmit)
        {
            //Get PolicyRouting Info
            PolicyRouting policyRouting = new PolicyRouting();

            policyRouting = policyAirCabinGroupItemViewModel.PolicyRouting;

            //Get PolicyAirCabinGroupItem Info
            PolicyAirCabinGroupItem policyAirCabinGroupItem = new PolicyAirCabinGroupItem();

            policyAirCabinGroupItem = policyAirCabinGroupItemViewModel.PolicyAirCabinGroupItem;

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

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

            //Update from+to fields from form to correct properties
            policyRoutingRepository.EditPolicyRouting(policyRouting);
            try
            {
                policyAirCabinGroupItemRepository.Add(policyAirCabinGroupItem, policyRouting);
            }
            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"));
            }

            //Send to new form based on submit button pressed
            switch (btnSubmit)
            {
            case "Save":
                return(RedirectToAction("List", new { id = policyAirCabinGroupItem.PolicyGroupId }));

            default:
                return(RedirectToAction("CreatePolicyRouting", new { id = policyAirCabinGroupItem.PolicyGroupId, policyAirCabinGroupItemId = policyAirCabinGroupItem.PolicyAirCabinGroupItemId }));
            }
        }
Esempio n. 5
0
        // GET: /Create
        public ActionResult Create(int id)
        {
            PolicyGroup policyGroup = policyGroupRepository.GetGroup(id);

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

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

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

            PolicyAirCabinGroupItem policyAirCabinGroupItem = new PolicyAirCabinGroupItem();


            //Populate List of AirlineCabins
            AirlineCabinRepository airlineCabinRepository = new AirlineCabinRepository();
            SelectList             airlineCabins          = new SelectList(airlineCabinRepository.GetAllAirlineCabins().ToList(), "AirlineCabinCode", "AirlineCabinDefaultDescription");

            ViewData["AirlineCabinCodeList"] = airlineCabins;

            //populate new PolicyAirCabinGroupItem with known PolicyGroup Information
            policyAirCabinGroupItem.PolicyGroupId   = id;
            policyAirCabinGroupItem.PolicyGroupName = policyGroup.PolicyGroupName;

            PolicyRouting policyRouting = new PolicyRouting();

            policyRouting.FromGlobalFlag = false;
            policyRouting.ToGlobalFlag   = false;

            PolicyAirCabinGroupItemViewModel policyAirCabinGroupItemViewModel = new PolicyAirCabinGroupItemViewModel(policyGroup, policyAirCabinGroupItem, policyRouting);

            //Show 'Create' Form
            return(View(policyAirCabinGroupItemViewModel));
        }