public ActionResult Delete(int id, string languageCode)
        {
            //Get Item
            PolicyAirVendorGroupItemLanguage policyAirVendorGroupItemLanguage = new PolicyAirVendorGroupItemLanguage();

            policyAirVendorGroupItemLanguage = policyAirVendorGroupItemLanguageRepository.GetItem(id, languageCode);

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

            //Check AccessRights
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);
            RolesRepository rolesRepository = new RolesRepository();

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

            //Add Linked Information
            policyAirVendorGroupItemLanguageRepository.EditItemForDisplay(policyAirVendorGroupItemLanguage);

            //Return View
            return(View(policyAirVendorGroupItemLanguage));
        }
Ejemplo n.º 2
0
        // GET: /View
        public ActionResult View(int id)
        {
            //Get PolicyAirVendorGroupItem
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);

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


            //populate new PolicyAirVendorGroupItem with known PolicyGroup Information
            policyAirVendorGroupItemRepository.EditItemForDisplay(policyAirVendorGroupItem);

            //Policy Group
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyAirVendorGroupItem.PolicyGroupId);

            //add the PolicyRouting information
            PolicyRouting policyRouting = policyRoutingRepository.GetPolicyRouting(policyAirVendorGroupItem.PolicyRoutingId);

            policyRoutingRepository.EditForDisplay(policyRouting);
            PolicyAirVendorGroupItemVM policyAirVendorGroupItemViewModel = new PolicyAirVendorGroupItemVM(policyGroup, policyAirVendorGroupItem, policyRouting);

            //Show 'Create' Form
            return(View(policyAirVendorGroupItemViewModel));
        }
        // GET: /Edit
        public ActionResult Edit(int id, string languageCode)
        {
            //Get Item
            PolicyAirVendorGroupItemLanguage policyAirVendorGroupItemLanguage = new PolicyAirVendorGroupItemLanguage();

            policyAirVendorGroupItemLanguage = policyAirVendorGroupItemLanguageRepository.GetItem(id, languageCode);

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

            //Check AccessRights
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);
            RolesRepository rolesRepository = new RolesRepository();

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

            //Language SelectList
            SelectList languageList = new SelectList(policyAirVendorGroupItemLanguageRepository.GetUnUsedLanguages(id).ToList(), "LanguageCode", "LanguageName");

            ViewData["Languages"] = languageList;

            policyAirVendorGroupItemLanguageRepository.EditItemForDisplay(policyAirVendorGroupItemLanguage);
            return(View(policyAirVendorGroupItemLanguage));
        }
Ejemplo n.º 4
0
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicyAirVendorGroupItemLanguage policyAirVendorGroupItemLanguage)
        {
            //Add LanguageName
            if (policyAirVendorGroupItemLanguage.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(policyAirVendorGroupItemLanguage.LanguageCode);
                if (language != null)
                {
                    policyAirVendorGroupItemLanguage.LanguageName = language.LanguageName;
                }
            }

            //Add PolicyGroup Information
            PolicyAirVendorGroupItemRepository policyAirVendorGroupItemRepository = new PolicyAirVendorGroupItemRepository();
            PolicyAirVendorGroupItem           policyAirVendorGroupItem           = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(policyAirVendorGroupItemLanguage.PolicyAirVendorGroupItemId);


            if (policyAirVendorGroupItem != null)
            {
                policyAirVendorGroupItemRepository.EditItemForDisplay(policyAirVendorGroupItem);
                policyAirVendorGroupItemLanguage.PolicyGroupName = policyAirVendorGroupItem.PolicyGroupName;
                policyAirVendorGroupItemLanguage.PolicyGroupId   = policyAirVendorGroupItem.PolicyGroupId;
            }
        }
Ejemplo n.º 5
0
        // GET: /Create
        public ActionResult Create(int id)
        {
            PolicyGroup policyGroup = new 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"));
            }


            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            //Populate List of PolicyAirStatuses
            PolicyAirStatusRepository policyAirStatusRepository = new PolicyAirStatusRepository();
            SelectList policyAirStatuses = new SelectList(policyAirStatusRepository.GetAllPolicyAirStatuses().ToList(), "PolicyAirStatusId", "PolicyAirStatusDescription");

            ViewData["PolicyAirStatusList"] = policyAirStatuses;

            //Populate List of Products
            ProductRepository productRepository = new ProductRepository();
            SelectList        products          = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName");

            ViewData["ProductList"] = products;

            //Populate List of AirVendorRankings
            SelectList airVendorRankings = new SelectList(policyAirVendorGroupItemRepository.AirVendorRankings().ToList(), "Value", "Text", policyAirVendorGroupItem.AirVendorRanking);

            ViewData["AirVendorRankings"] = airVendorRankings;

            //populate new PolicyAirVendorGroupItem with known PolicyGroup Information
            policyAirVendorGroupItem.PolicyGroupId   = id;
            policyAirVendorGroupItem.PolicyGroupName = policyGroup.PolicyGroupName;

            PolicyRouting policyRouting = new PolicyRouting();

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

            PolicyAirVendorGroupItemVM policyAirVendorGroupItemViewModel = new PolicyAirVendorGroupItemVM(policyGroup, policyAirVendorGroupItem, policyRouting);

            //Show 'Create' Form
            return(View(policyAirVendorGroupItemViewModel));
        }
Ejemplo n.º 6
0
        // GET: /Edit
        public ActionResult Edit(int id)
        {
            //Get PolicyAirVendorGroupItem
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);

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

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

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

            //Populate List of PolicyAirStatuses
            PolicyAirStatusRepository policyAirStatusRepository = new PolicyAirStatusRepository();
            SelectList policyAirStatuses = new SelectList(policyAirStatusRepository.GetAllPolicyAirStatuses().ToList(), "PolicyAirStatusId", "PolicyAirStatusDescription");

            ViewData["PolicyAirStatusList"] = policyAirStatuses;

            //Populate List of Products
            ProductRepository productRepository = new ProductRepository();
            SelectList        products          = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName", policyAirVendorGroupItem.ProductId);

            ViewData["ProductList"] = products;

            //Populate List of Products
            SelectList airVendorRankings = new SelectList(policyAirVendorGroupItemRepository.AirVendorRankings().ToList(), "Value", "Text", policyAirVendorGroupItem.AirVendorRanking);

            ViewData["AirVendorRankings"] = airVendorRankings;

            //populate new PolicyAirVendorGroupItem with known PolicyGroup Information
            policyAirVendorGroupItemRepository.EditItemForDisplay(policyAirVendorGroupItem);

            //Policy Group
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyAirVendorGroupItem.PolicyGroupId);

            //Add the PolicyRouting information
            PolicyRouting policyRouting = policyRoutingRepository.GetPolicyRouting(policyAirVendorGroupItem.PolicyRoutingId);
            PolicyAirVendorGroupItemVM policyAirVendorGroupItemViewModel = new PolicyAirVendorGroupItemVM(policyGroup, policyAirVendorGroupItem, policyRouting);

            //Show 'Edit' Form
            return(View(policyAirVendorGroupItemViewModel));
        }
        //GET:List
        public ActionResult List(int id, int?page, string sortField, int?sortOrder)
        {
            //Get PolicyAirVendorGroupItem
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);

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

            //Set Access Rights
            ViewData["Access"] = "";
            RolesRepository rolesRepository = new RolesRepository();

            if (rolesRepository.HasWriteAccessToPolicyGroup(policyAirVendorGroupItem.PolicyGroupId))
            {
                ViewData["Access"] = "WriteAccess";
            }

            //Parent Information
            ViewData["PolicyAirVendorGroupItemID"] = policyAirVendorGroupItem.PolicyAirVendorGroupItemId;
            ViewData["PolicyGroupID"]   = policyAirVendorGroupItem.PolicyGroupId;
            ViewData["PolicyGroupName"] = policyGroupRepository.GetGroup(policyAirVendorGroupItem.PolicyGroupId).PolicyGroupName;


            //SortField+SortOrder settings
            if (sortField != "AirlineAdvice")
            {
                sortField = "LanguageName";
            }
            if (sortOrder == 1)
            {
                ViewData["NewSortOrder"]     = 0;
                ViewData["CurrentSortOrder"] = 1;
            }
            else
            {
                ViewData["NewSortOrder"]     = 1;
                ViewData["CurrentSortOrder"] = 0;
                sortOrder = 0;
            }

            //Get data
            var cwtPaginatedList = policyAirVendorGroupItemLanguageRepository.PagePolicyAirVendorGroupItemAirlineAdvice(id, page ?? 1, sortField, sortOrder ?? 0);

            return(View(cwtPaginatedList));
        }
        public ActionResult Delete(int id, string languageCode, FormCollection collection)
        {
            //Get Item
            PolicyAirVendorGroupItemLanguage policyAirVendorGroupItemLanguage = new PolicyAirVendorGroupItemLanguage();

            policyAirVendorGroupItemLanguage = policyAirVendorGroupItemLanguageRepository.GetItem(id, languageCode);

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

            //Check AccessRights
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);
            RolesRepository rolesRepository = new RolesRepository();

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

            //Delete Item
            try
            {
                policyAirVendorGroupItemLanguage.VersionNumber = Int32.Parse(collection["VersionNumber"]);
                policyAirVendorGroupItemLanguageRepository.Delete(policyAirVendorGroupItemLanguage);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/AirlineAdvice.mvc/Delete/" + policyAirVendorGroupItemLanguage.PolicyAirVendorGroupItemId.ToString() + "/" + policyAirVendorGroupItemLanguage.LanguageCode;
                    return(View("VersionError"));
                }
                //Generic Error
                ViewData["Message"] = "There was a problem with your request, please see the log file or contact an administrator for details";
                return(View("Error"));
            }


            //Return
            return(RedirectToAction("List", new { id = policyAirVendorGroupItemLanguage.PolicyAirVendorGroupItemId }));
        }
        public ActionResult Create(PolicyAirVendorGroupItemLanguage policyAirVendorGroupItemLanguage)
        {
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(policyAirVendorGroupItemLanguage.PolicyAirVendorGroupItemId);

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

            RolesRepository rolesRepository = new RolesRepository();

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

            //Update  Model from Form
            try
            {
                UpdateModel(policyAirVendorGroupItemLanguage);
            }
            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"));
            }


            policyAirVendorGroupItemLanguageRepository.Add(policyAirVendorGroupItemLanguage);

            return(RedirectToAction("List", new { id = policyAirVendorGroupItem.PolicyAirVendorGroupItemId }));
        }
Ejemplo n.º 10
0
        public ActionResult Delete(int id)
        {
            //Get PolicyAirVendorGroupItem
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);

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

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

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

            //populate new PolicyAirVendorGroupItem with known PolicyGroup Information
            policyAirVendorGroupItemRepository.EditItemForDisplay(policyAirVendorGroupItem);

            //Policy Group
            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyAirVendorGroupItem.PolicyGroupId);

            //add the PolicyRouting information
            PolicyRouting policyRouting = policyRoutingRepository.GetPolicyRouting(policyAirVendorGroupItem.PolicyRoutingId);

            policyRoutingRepository.EditForDisplay(policyRouting);
            PolicyAirVendorGroupItemVM policyAirVendorGroupItemViewModel = new PolicyAirVendorGroupItemVM(policyGroup, policyAirVendorGroupItem, policyRouting);

            //Show 'Create' Form
            return(View(policyAirVendorGroupItemViewModel));
        }
Ejemplo n.º 11
0
        public ActionResult Edit(int id, PolicyAirVendorGroupItemVM policyAirVendorGroupItemViewModel, FormCollection collection)
        {
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);

            PolicyRouting policyRouting = new PolicyRouting();

            policyRouting = policyAirVendorGroupItemViewModel.PolicyRouting;

            //Check Exists
            if (policyAirVendorGroupItem == null || policyRouting == null)
            {
                ViewData["ActionMethod"] = "EditPost";
                return(View("RecordDoesNotExistError"));
            }

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

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

            //Preferred AirStatus, Ranking is null unless Preferred
            if (policyAirVendorGroupItem.AirVendorRanking != PreferredAirStatusId)
            {
                policyAirVendorGroupItem.AirVendorRanking = null;
            }

            //Update Item from Form
            try
            {
                UpdateModel(policyAirVendorGroupItem, "PolicyAirVendorGroupItem");
                UpdateModel(policyRouting, "PolicyRouting");
            }
            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"));
            }

            //Edit Routing
            policyRoutingRepository.EditPolicyRouting(policyRouting);

            //Database Update
            try
            {
                policyAirVendorGroupItemRepository.Update(policyAirVendorGroupItem, policyRouting);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicyAirVendorGroupItem.mvc/Edit/" + policyAirVendorGroupItem.PolicyAirVendorGroupItemId;
                    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 to Form
            return(RedirectToAction("List", new { id = policyAirVendorGroupItem.PolicyGroupId }));
        }
Ejemplo n.º 12
0
        public ActionResult CreatePolicyRouting(int policyAirVendorGroupItemId, PolicyRouting policyRouting, string btnSubmit)
        {
            //Get PolicyAirVendorGroupItem (Original)
            PolicyAirVendorGroupItem policyAirVendorGroupItemOriginal = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItemOriginal = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(policyAirVendorGroupItemId);

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

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

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policyAirVendorGroupItemOriginal.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);

            //Copy policyAirVendorGroupItem from original
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem.PolicyAirStatusId   = policyAirVendorGroupItemOriginal.PolicyAirStatusId;
            policyAirVendorGroupItem.EnabledDate         = policyAirVendorGroupItemOriginal.EnabledDate;
            policyAirVendorGroupItem.ExpiryDate          = policyAirVendorGroupItemOriginal.ExpiryDate;
            policyAirVendorGroupItem.EnabledFlag         = policyAirVendorGroupItemOriginal.EnabledFlag;
            policyAirVendorGroupItem.PolicyGroupId       = policyAirVendorGroupItemOriginal.PolicyGroupId;
            policyAirVendorGroupItem.ProductId           = policyAirVendorGroupItemOriginal.ProductId;
            policyAirVendorGroupItem.SupplierCode        = policyAirVendorGroupItemOriginal.SupplierCode;
            policyAirVendorGroupItem.TravelDateValidFrom = policyAirVendorGroupItemOriginal.TravelDateValidFrom;
            policyAirVendorGroupItem.TravelDateValidTo   = policyAirVendorGroupItemOriginal.TravelDateValidTo;
            policyAirVendorGroupItem.AirVendorRanking    = policyAirVendorGroupItemOriginal.AirVendorRanking;

            //Save policyAirVendorGroupItem to DB
            try
            {
                policyAirVendorGroupItemRepository.Add(policyAirVendorGroupItem, 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
            int policyAirVendorGroupItemID = policyAirVendorGroupItem.PolicyAirVendorGroupItemId;
            int PolicyGroupID = policyAirVendorGroupItem.PolicyGroupId;

            switch (btnSubmit)
            {
            case "Save":
                return(RedirectToAction("List", new { id = PolicyGroupID }));

            default:
                return(RedirectToAction("CreatePolicyRouting", new { id = PolicyGroupID, policyAirVendorGroupItemId = policyAirVendorGroupItemID }));
            }
        }
Ejemplo n.º 13
0
        public ActionResult Create(PolicyAirVendorGroupItemVM policyAirVendorGroupItemViewModel, string btnSubmit)
        {
            //Get PolicyRouting Info
            PolicyRouting policyRouting = new PolicyRouting();

            policyRouting = policyAirVendorGroupItemViewModel.PolicyRouting;

            //Get PolicyAirVendorGroupItem Info
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemViewModel.PolicyAirVendorGroupItem;

            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyAirVendorGroupItem.PolicyGroupId);

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

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

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

            //Edit Routing
            policyRoutingRepository.EditPolicyRouting(policyRouting);

            //Preferred AirStatus, Ranking is null unless Preferred
            if (policyAirVendorGroupItem.PolicyAirStatusId != PreferredAirStatusId)
            {
                policyAirVendorGroupItem.AirVendorRanking = null;
            }

            //Save To DB
            try
            {
                policyAirVendorGroupItemRepository.Add(policyAirVendorGroupItem, 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
            int policyAirVendorGroupItemID = policyAirVendorGroupItem.PolicyAirVendorGroupItemId;
            int PolicyGroupID = policyAirVendorGroupItem.PolicyGroupId;

            switch (btnSubmit)
            {
            case "Save":
                return(RedirectToAction("List", new { id = PolicyGroupID }));

            default:
                return(RedirectToAction("CreatePolicyRouting", new { id = PolicyGroupID, policyAirVendorGroupItemId = policyAirVendorGroupItemID }));
            }
        }
Ejemplo n.º 14
0
 public PolicyAirVendorGroupItemVM(PolicyGroup policyGroup, PolicyAirVendorGroupItem policyAirVendorGroupItem, PolicyRouting policyRouting)
 {
     PolicyGroup = policyGroup;
     PolicyAirVendorGroupItem = policyAirVendorGroupItem;
     PolicyRouting            = policyRouting;
 }
        public ActionResult Edit(int id, string languageCode, FormCollection formCollection)
        {
            //Get Item
            PolicyAirVendorGroupItemLanguage policyAirVendorGroupItemLanguage = new PolicyAirVendorGroupItemLanguage();

            policyAirVendorGroupItemLanguage = policyAirVendorGroupItemLanguageRepository.GetItem(id, languageCode);

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

            //Check AccessRights
            PolicyAirVendorGroupItem policyAirVendorGroupItem = new PolicyAirVendorGroupItem();

            policyAirVendorGroupItem = policyAirVendorGroupItemRepository.GetPolicyAirVendorGroupItem(id);
            RolesRepository rolesRepository = new RolesRepository();

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

            //Update Item from Form
            try
            {
                UpdateModel(policyAirVendorGroupItemLanguage);
            }
            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"));
            }



            //Update AirlineAdvice
            try
            {
                policyAirVendorGroupItemLanguageRepository.Update(policyAirVendorGroupItemLanguage);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/AirlineAdvice.mvc/Edit/" + policyAirVendorGroupItemLanguage.PolicyAirVendorGroupItemId.ToString();
                    return(View("VersionError"));
                }

                //Generic Error
                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 = policyAirVendorGroupItemLanguage.PolicyAirVendorGroupItemId }));
        }