Example #1
0
        // GET: /View
        public ActionResult View(int id)
        {
            //Get PolicyCarTypeGroupItem
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(id);

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

            //Create ViewModel
            PolicyCityGroupItemVM policyCityGroupItemVM = new PolicyCityGroupItemVM();

            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyCityGroupItem.PolicyGroupId);
            policyCityGroupItemVM.PolicyGroup = policyGroup;

            policyCityGroupItemVM.PolicyCityGroupItem = policyCityGroupItem;

            //Return Form to Users
            return(View(policyCityGroupItemVM));
        }
Example #2
0
        // GET: /Edit
        public ActionResult Edit(int id, string languageCode)
        {
            //Get Item
            PolicyCityGroupItemLanguage policyCityGroupItemLanguage = new PolicyCityGroupItemLanguage();

            policyCityGroupItemLanguage = policyCityGroupItemLanguageRepository.GetItem(id, languageCode);

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

            //Check AccessRights
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(id);
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCityGroupItem.PolicyGroupId))
            {
                return(View("Error"));
            }

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

            ViewData["Languages"] = languageList;

            policyCityGroupItemLanguageRepository.EditItemForDisplay(policyCityGroupItemLanguage);
            return(View(policyCityGroupItemLanguage));
        }
Example #3
0
        public ActionResult Delete(int id, string languageCode)
        {
            //Get Item
            PolicyCityGroupItemLanguage policyCityGroupItemLanguage = new PolicyCityGroupItemLanguage();

            policyCityGroupItemLanguage = policyCityGroupItemLanguageRepository.GetItem(id, languageCode);

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

            //Check AccessRights
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(id);
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCityGroupItem.PolicyGroupId))
            {
                return(View("Error"));
            }

            //Add Linked Information
            policyCityGroupItemLanguageRepository.EditItemForDisplay(policyCityGroupItemLanguage);

            //Return View
            return(View(policyCityGroupItemLanguage));
        }
        //Add Data From Linked Tables for Display
        public void EditItemForDisplay(PolicyCityGroupItemLanguage policyCityGroupItemLanguage)
        {
            //Add LanguageName
            if (policyCityGroupItemLanguage.LanguageCode != null)
            {
                LanguageRepository languageRepository = new LanguageRepository();
                Language           language           = new Language();
                language = languageRepository.GetLanguage(policyCityGroupItemLanguage.LanguageCode);
                if (language != null)
                {
                    policyCityGroupItemLanguage.LanguageName = language.LanguageName;
                }
            }

            //Add PolicyGroupName
            PolicyCityGroupItemRepository policyCityGroupItemRepository = new PolicyCityGroupItemRepository();
            PolicyCityGroupItem           policyCityGroupItem           = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(policyCityGroupItemLanguage.PolicyCityGroupItemId);


            if (policyCityGroupItem != null)
            {
                PolicyGroupRepository policyGroupRepository = new PolicyGroupRepository();
                PolicyGroup           policyGroup           = new PolicyGroup();
                policyGroup = policyGroupRepository.GetGroup(policyCityGroupItem.PolicyGroupId);

                //policyCityGroupItemRepository.EditItemForDisplay(policyCityGroupItem);
                policyCityGroupItemLanguage.PolicyGroupName = policyGroup.PolicyGroupName;
                policyCityGroupItemLanguage.PolicyGroupId   = policyCityGroupItem.PolicyGroupId;
            }
        }
Example #5
0
        public ActionResult Edit(PolicyCityGroupItemVM policyCityGroupItemVM)
        {
            //Get PolicyCityGroupItem
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(policyCityGroupItemVM.PolicyCityGroupItem.PolicyCityGroupItemId);


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

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

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

            //Update Model From Form + Validate against DB
            try
            {
                UpdateModel <PolicyCityGroupItem>(policyCityGroupItemVM.PolicyCityGroupItem, "PolicyCityGroupItem");
            }
            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"));
            }

            //Save To DB
            try
            {
                policyCityGroupItemRepository.Update(policyCityGroupItemVM.PolicyCityGroupItem);
            }
            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", new { id = policyCityGroupItemVM.PolicyCityGroupItem.PolicyGroupId }));
        }
Example #6
0
        //Delete
        public void Delete(PolicyCityGroupItem policyCityGroupItem)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_DeletePolicyCityGroupItem_v1(
                policyCityGroupItem.PolicyCityGroupItemId,
                adminUserGuid,
                policyCityGroupItem.VersionNumber
                );
        }
Example #7
0
        public ActionResult Create(PolicyCityGroupItemLanguage policyCityGroupItemLanguage)
        {
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(policyCityGroupItemLanguage.PolicyCityGroupItemId);

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

            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCityGroupItem.PolicyGroupId))
            {
                //AccessRights Error
                return(View("Error"));
            }

            //Update  Model from Form
            try
            {
                UpdateModel(policyCityGroupItemLanguage);
            }
            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
            {
                policyCityGroupItemLanguageRepository.Add(policyCityGroupItemLanguage);
            }
            catch
            {
                //Insert Error
                return(View("Error"));
            }


            return(RedirectToAction("List", new { id = policyCityGroupItem.PolicyCityGroupItemId }));
        }
Example #8
0
        //GET:List
        public ActionResult List(int id, int?page, string sortField, int?sortOrder)
        {
            //Get PolicyCityGroupItem
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(id);

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

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

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

            //Parent Information
            ViewData["PolicyCityGroupItemId"] = policyCityGroupItem.PolicyCityGroupItemId;
            ViewData["PolicyGroupID"]         = policyCityGroupItem.PolicyGroupId;
            ViewData["PolicyGroupName"]       = policyGroupRepository.GetGroup(policyCityGroupItem.PolicyGroupId).PolicyGroupName;


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

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

            return(View(cwtPaginatedList));
        }
Example #9
0
        public ActionResult Delete(int id, string languageCode, FormCollection collection)
        {
            //Get Item
            PolicyCityGroupItemLanguage policyCityGroupItemLanguage = new PolicyCityGroupItemLanguage();

            policyCityGroupItemLanguage = policyCityGroupItemLanguageRepository.GetItem(id, languageCode);

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

            //Check AccessRights
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(id);
            RolesRepository rolesRepository = new RolesRepository();

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCityGroupItem.PolicyGroupId))
            {
                return(View("Error"));
            }

            //Delete Item
            try
            {
                policyCityGroupItemLanguage.VersionNumber = Int32.Parse(collection["VersionNumber"]);
                policyCityGroupItemLanguageRepository.Delete(policyCityGroupItemLanguage);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/CityAdvice.mvc/Delete/" + policyCityGroupItemLanguage.PolicyCityGroupItemId.ToString() + "/" + policyCityGroupItemLanguage.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 = policyCityGroupItemLanguage.PolicyCityGroupItemId }));
        }
Example #10
0
        public ActionResult Delete(PolicyCityGroupItemVM policyCityGroupItemVM)
        {
            //Get PolicyCityGroupItem
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(policyCityGroupItemVM.PolicyCityGroupItem.PolicyCityGroupItemId);

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

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

            if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCityGroupItem.PolicyGroupId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }
            //Delete Item
            try
            {
                policyCityGroupItemRepository.Delete(policyCityGroupItemVM.PolicyCityGroupItem);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicyCityGroupItem.mvc/Delete/" + policyCityGroupItem.PolicyCityGroupItemId.ToString();
                    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
            return(RedirectToAction("List", new { id = policyCityGroupItem.PolicyGroupId }));
        }
Example #11
0
        //Add
        public void Add(PolicyCityGroupItem policyCityGroupItem)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertPolicyCityGroupItem_v1(
                policyCityGroupItem.PolicyGroupId,
                policyCityGroupItem.PolicyCityStatusId,
                policyCityGroupItem.EnabledFlag,
                policyCityGroupItem.EnabledDate,
                policyCityGroupItem.ExpiryDate,
                policyCityGroupItem.TravelDateValidFrom,
                policyCityGroupItem.TravelDateValidTo,
                policyCityGroupItem.CityCode,
                policyCityGroupItem.InheritFromParentFlag,
                adminUserGuid
                );
        }
Example #12
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"));
            }

            //Create ViewModel
            PolicyCityGroupItemVM policyCityGroupItemVM = new PolicyCityGroupItemVM();

            policyCityGroupItemVM.PolicyGroup = policyGroup;

            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem.PolicyGroupId         = policyGroup.PolicyGroupId;
            policyCityGroupItemVM.PolicyCityGroupItem = policyCityGroupItem;

            //Statuses
            PolicyCityStatusRepository policyCityStatusRepository = new PolicyCityStatusRepository();

            policyCityGroupItemVM.PolicyCityStatuses = new SelectList(policyCityStatusRepository.GetAllPolicyCityStatuses().ToList(), "PolicyCityStatusId", "PolicyCityStatusDescription");

            //Return Form to Users
            return(View(policyCityGroupItemVM));
        }
Example #13
0
        public ActionResult Delete(int id)
        {
            //Get PolicyCarTypeGroupItem
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(id);

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

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

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

            //Create ViewModel
            PolicyCityGroupItemVM policyCityGroupItemVM = new PolicyCityGroupItemVM();

            PolicyGroup policyGroup = new PolicyGroup();

            policyGroup = policyGroupRepository.GetGroup(policyCityGroupItem.PolicyGroupId);
            policyCityGroupItemVM.PolicyGroup = policyGroup;

            policyCityGroupItemVM.PolicyCityGroupItem = policyCityGroupItem;

            //Return Form to Users
            return(View(policyCityGroupItemVM));
        }
Example #14
0
        public ActionResult Edit(int id, string languageCode, FormCollection formCollection)
        {
            //Get Item
            PolicyCityGroupItemLanguage policyCityGroupItemLanguage = new PolicyCityGroupItemLanguage();

            policyCityGroupItemLanguage = policyCityGroupItemLanguageRepository.GetItem(id, languageCode);

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

            //Check AccessRights
            PolicyCityGroupItem policyCityGroupItem = new PolicyCityGroupItem();

            policyCityGroupItem = policyCityGroupItemRepository.GetPolicyCityGroupItem(id);
            RolesRepository rolesRepository = new RolesRepository();

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

            //Update Item from Form
            try
            {
                UpdateModel(policyCityGroupItemLanguage);
            }
            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 CityAdvice
            try
            {
                policyCityGroupItemLanguageRepository.Update(policyCityGroupItemLanguage);
            }
            catch (SqlException ex)
            {
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/CityAdvice.mvc/Edit/" + policyCityGroupItemLanguage.PolicyCityGroupItemId.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 = policyCityGroupItemLanguage.PolicyCityGroupItemId }));
        }
Example #15
0
 public PolicyCityGroupItemVM(PolicyGroup policyGroup, PolicyCityGroupItem policyCityGroupItem, IEnumerable <SelectListItem> policyCityStatuses)
 {
     PolicyGroup         = policyGroup;
     PolicyCityGroupItem = policyCityGroupItem;
     PolicyCityStatuses  = policyCityStatuses;
 }