Exemplo n.º 1
0
        public ActionResult Edit(PolicyHotelOtherGroupItemLanguageVM policyHotelOtherGroupItemLanguageVM, FormCollection formCollection)
        {
            //Get Item
            PolicyHotelOtherGroupItemLanguage policyHotelOtherGroupItemLanguage = new PolicyHotelOtherGroupItemLanguage();

            policyHotelOtherGroupItemLanguage = policyHotelOtherGroupItemLanguageRepository.GetPolicyHotelOtherGroupItemLanguage(policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.PolicyHotelOtherGroupItemLanguageId);

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

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

            //Database Update
            try
            {
                policyHotelOtherGroupItemLanguageRepository.Edit(policyHotelOtherGroupItemLanguageVM);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    return(View("NonUniqueNameError"));
                }
                //Versioning Error
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicyHotelOtherGroupItemLanguage.mvc/Edit/" + policyHotelOtherGroupItemLanguage.PolicyHotelOtherGroupItemLanguageId;
                    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 = policyHotelOtherGroupItemLanguageVM.PolicyOtherGroupHeader.PolicyOtherGroupHeaderId, policyGroupId = policyHotelOtherGroupItemLanguageVM.PolicyGroup.PolicyGroupId }));
        }
Exemplo n.º 2
0
        // GET: /PolicyHotelOtherGroupItemLanguage/Edit
        public ActionResult Edit(int id, int policyGroupId, int policyOtherGroupHeaderId)
        {
            PolicyHotelOtherGroupItemLanguageVM policyHotelOtherGroupItemLanguageVM = new PolicyHotelOtherGroupItemLanguageVM();

            //Check Item Exists
            PolicyHotelOtherGroupItemLanguage policyHotelOtherGroupItemLanguage = new PolicyHotelOtherGroupItemLanguage();

            policyHotelOtherGroupItemLanguage = policyHotelOtherGroupItemLanguageRepository.GetPolicyHotelOtherGroupItemLanguage(id);
            if (policyHotelOtherGroupItemLanguage == 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"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }

            policyHotelOtherGroupItemLanguageVM.PolicyOtherGroupHeader            = policyOtherGroupHeader;
            policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage = policyHotelOtherGroupItemLanguage;
            policyGroupRepository.EditGroupForDisplay(policyGroup);
            policyHotelOtherGroupItemLanguageVM.PolicyGroup = policyGroup;

            //Languages
            List <Language>    availableLanguages = policyHotelOtherGroupItemLanguageRepository.GetAvailableLanguages(policyOtherGroupHeaderId, policyGroup.PolicyGroupId).ToList();
            Language           selectedLanguage   = new Language();
            LanguageRepository languageRepository = new LanguageRepository();

            selectedLanguage = languageRepository.GetLanguage(policyHotelOtherGroupItemLanguage.LanguageCode);
            if (selectedLanguage != null)
            {
                availableLanguages.Add(selectedLanguage);
            }

            SelectList languages = new SelectList(availableLanguages.OrderBy(x => x.LanguageCode), "LanguageCode", "LanguageName", policyHotelOtherGroupItemLanguage.LanguageCode);

            policyHotelOtherGroupItemLanguageVM.Languages = languages;

            return(View(policyHotelOtherGroupItemLanguageVM));
        }
Exemplo n.º 3
0
        ////Edit
        public void Edit(PolicyHotelOtherGroupItemLanguageVM policyHotelOtherGroupItemLanguageVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_UpdatePolicyHotelOtherGroupItemLanguage_v1(
                policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.PolicyHotelOtherGroupItemLanguageId,
                policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.Translation,
                policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.LanguageCode,
                adminUserGuid,
                policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.VersionNumber
                );
        }
Exemplo n.º 4
0
        //Add
        public void Add(PolicyHotelOtherGroupItemLanguageVM policyHotelOtherGroupItemLanguageVM)
        {
            string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0];

            db.spDesktopDataAdmin_InsertPolicyHotelOtherGroupItemLanguage_v1(
                policyHotelOtherGroupItemLanguageVM.PolicyGroup.PolicyGroupId,
                policyHotelOtherGroupItemLanguageVM.PolicyOtherGroupHeader.PolicyOtherGroupHeaderId,
                policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.Translation,
                policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.LanguageCode,
                adminUserGuid
                );
        }
Exemplo n.º 5
0
        public ActionResult Delete(PolicyHotelOtherGroupItemLanguageVM policyHotelOtherGroupItemLanguageVM)
        {
            //Check Valid Item passed in Form
            if (policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage == null)
            {
                ViewData["ActionMethod"] = "DeletePost";
                return(View("RecordDoesNotExistError"));
            }

            //Get Item From Database
            PolicyHotelOtherGroupItemLanguage policyHotelOtherGroupItemLanguage = new PolicyHotelOtherGroupItemLanguage();

            policyHotelOtherGroupItemLanguage = policyHotelOtherGroupItemLanguageRepository.GetPolicyHotelOtherGroupItemLanguage(policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.PolicyHotelOtherGroupItemLanguageId);

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

            //Delete Form Item
            try
            {
                policyHotelOtherGroupItemLanguageRepository.Delete(policyHotelOtherGroupItemLanguage);
            }
            catch (SqlException ex)
            {
                //Versioning Error - go to standard versionError page
                if (ex.Message == "SQLVersioningError")
                {
                    ViewData["ReturnURL"] = "/PolicyHotelOtherGroupItemLanguage.mvc/Delete/" + policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage.PolicyHotelOtherGroupItemLanguageId;
                    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 = policyHotelOtherGroupItemLanguageVM.PolicyOtherGroupHeader.PolicyOtherGroupHeaderId, policyGroupId = policyHotelOtherGroupItemLanguageVM.PolicyGroup.PolicyGroupId }));
        }
Exemplo n.º 6
0
        public ActionResult Delete(int id, int policyGroupId, int policyOtherGroupHeaderId)
        {
            PolicyHotelOtherGroupItemLanguageVM policyHotelOtherGroupItemLanguageVM = new PolicyHotelOtherGroupItemLanguageVM();

            //Check Item Exists
            PolicyHotelOtherGroupItemLanguage policyHotelOtherGroupItemLanguage = new PolicyHotelOtherGroupItemLanguage();

            policyHotelOtherGroupItemLanguage = policyHotelOtherGroupItemLanguageRepository.GetPolicyHotelOtherGroupItemLanguage(id);
            if (policyHotelOtherGroupItemLanguage == 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"] = "CreateGet";
                return(View("RecordDoesNotExistError"));
            }

            policyHotelOtherGroupItemLanguageVM.PolicyOtherGroupHeader            = policyOtherGroupHeader;
            policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage = policyHotelOtherGroupItemLanguage;
            policyGroupRepository.EditGroupForDisplay(policyGroup);
            policyHotelOtherGroupItemLanguageVM.PolicyGroup = policyGroup;

            return(View(policyHotelOtherGroupItemLanguageVM));
        }
Exemplo n.º 7
0
        // GET: /PolicyHotelOtherGroupItemLanguage/Create
        public ActionResult Create(int id, int policyGroupId)
        {
            PolicyHotelOtherGroupItemLanguageVM policyHotelOtherGroupItemLanguageVM = new PolicyHotelOtherGroupItemLanguageVM();

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

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

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

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

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

            PolicyHotelOtherGroupItemLanguage policyHotelOtherGroupItemLanguage = new PolicyHotelOtherGroupItemLanguage();

            policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage = policyHotelOtherGroupItemLanguage;

            //Languages
            SelectList languages = new SelectList(policyHotelOtherGroupItemLanguageRepository.GetAvailableLanguages(id, policyGroupId).ToList(), "LanguageCode", "LanguageName");

            policyHotelOtherGroupItemLanguageVM.Languages = languages;

            return(View(policyHotelOtherGroupItemLanguageVM));
        }
Exemplo n.º 8
0
        public ActionResult Create(PolicyHotelOtherGroupItemLanguageVM policyHotelOtherGroupItemLanguageVM, FormCollection formCollection)
        {
            //Check Policy Exists
            PolicyGroup policyGroup = new PolicyGroup();

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

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

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

            //We need to extract group from groupVM
            PolicyHotelOtherGroupItemLanguage policyHotelOtherGroupItemLanguage = new PolicyHotelOtherGroupItemLanguage();

            policyHotelOtherGroupItemLanguage = policyHotelOtherGroupItemLanguageVM.PolicyHotelOtherGroupItemLanguage;
            if (policyHotelOtherGroupItemLanguage == null)
            {
                ViewData["Message"] = "ValidationError : missing item";;
                return(View("Error"));
            }

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

            //Database Update
            try
            {
                policyHotelOtherGroupItemLanguageRepository.Add(policyHotelOtherGroupItemLanguageVM);
            }
            catch (SqlException ex)
            {
                //Non-Unique Name
                if (ex.Message == "NonUniqueName")
                {
                    return(View("NonUniqueNameError"));
                }

                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"));
            }

            ViewData["NewSortOrder"] = 0;
            return(RedirectToAction("List", new { id = policyHotelOtherGroupItemLanguageVM.PolicyOtherGroupHeader.PolicyOtherGroupHeaderId, policyGroupId = policyHotelOtherGroupItemLanguageVM.PolicyGroup.PolicyGroupId }));
        }