// GET: /Create public ActionResult Create(int id) { PolicyGroup policyGroup = policyGroupRepository.GetGroup(id); 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")); } //Populate List of PolicyCountryStatuses PolicyCountryStatusRepository policyCountryStatusRepository = new PolicyCountryStatusRepository(); SelectList policyCountryStatuses = new SelectList(policyCountryStatusRepository.GetAllPolicyCountryStatuses().ToList(), "PolicyCountryStatusId", "PolicyCountryStatusDescription"); ViewData["PolicyCountryStatusList"] = policyCountryStatuses; //populateItem with known PolicyGroup Information PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem.PolicyGroupId = id; policyCountryGroupItem.PolicyGroupName = policyGroup.PolicyGroupName; //Show 'Create' Form return(View(policyCountryGroupItem)); }
public ActionResult Delete(int id) { //Get PolicyCountryGroupItem PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); //Check Exists if (policyCountryGroupItem == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { return(View("Error")); } //populate new PolicyHotelVendorGroupItem with known PolicyGroup Information policyCountryGroupItemRepository.EditItemForDisplay(policyCountryGroupItem); //Show 'Delete' Form return(View(policyCountryGroupItem)); }
//Add Data From Linked Tables for Display public void EditItemForDisplay(PolicyCountryGroupItem policyCountryGroupItem) { //PolicyGroupName PolicyGroupRepository policyGroupRepository = new PolicyGroupRepository(); PolicyGroup policyGroup = policyGroupRepository.GetGroup(policyCountryGroupItem.PolicyGroupId); policyCountryGroupItem.PolicyGroupName = policyGroup.PolicyGroupName; //PolicyCountryStatus if (policyCountryGroupItem.PolicyCountryStatusId != null) { int policyCountryStatusId = (int)policyCountryGroupItem.PolicyCountryStatusId; PolicyCountryStatusRepository policyCountryStatusRepository = new PolicyCountryStatusRepository(); PolicyCountryStatus policyCountryStatus = new PolicyCountryStatus(); policyCountryStatus = policyCountryStatusRepository.GetPolicyCountryStatus(policyCountryStatusId); if (policyCountryStatus != null) { policyCountryGroupItem.PolicyCountryStatusDescription = policyCountryStatus.PolicyCountryStatusDescription; } } //CountryName CountryRepository countryRepository = new CountryRepository(); Country country = new Country(); country = countryRepository.GetCountry(policyCountryGroupItem.CountryCode); if (country != null) { policyCountryGroupItem.CountryName = country.CountryName; } }
// GET: /Edit public ActionResult Edit(int id) { //Get PolicyCountryGroupItem PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); //Check Exists if (policyCountryGroupItem == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Populate List of PolicyCountryStatuses PolicyCountryStatusRepository policyCountryStatusRepository = new PolicyCountryStatusRepository(); SelectList policyCountryStatuses = new SelectList(policyCountryStatusRepository.GetAllPolicyCountryStatuses().ToList(), "PolicyCountryStatusId", "PolicyCountryStatusDescription"); ViewData["PolicyCountryStatusList"] = policyCountryStatuses; //Show 'Edit' Form policyCountryGroupItemRepository.EditItemForDisplay(policyCountryGroupItem); return(View(policyCountryGroupItem)); }
public ActionResult Delete(int id, string languageCode) { //Get Item PolicyCountryGroupItemLanguage policyCountryGroupItemLanguage = new PolicyCountryGroupItemLanguage(); policyCountryGroupItemLanguage = policyCountryGroupItemLanguageRepository.GetItem(id, languageCode); //Check Exists if (policyCountryGroupItemLanguage == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { return(View("Error")); } //Add Linked Information policyCountryGroupItemLanguageRepository.EditItemForDisplay(policyCountryGroupItemLanguage); //Return View return(View(policyCountryGroupItemLanguage)); }
// GET: /Edit public ActionResult Edit(int id, string languageCode) { //Get Item PolicyCountryGroupItemLanguage policyCountryGroupItemLanguage = new PolicyCountryGroupItemLanguage(); policyCountryGroupItemLanguage = policyCountryGroupItemLanguageRepository.GetItem(id, languageCode); //Check Exists if (policyCountryGroupItemLanguage == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { return(View("Error")); } //Language SelectList SelectList languageList = new SelectList(policyCountryGroupItemLanguageRepository.GetUnUsedLanguages(id).ToList(), "LanguageCode", "LanguageName"); ViewData["Languages"] = languageList; policyCountryGroupItemLanguageRepository.EditItemForDisplay(policyCountryGroupItemLanguage); return(View(policyCountryGroupItemLanguage)); }
//Add Data From Linked Tables for Display public void EditItemForDisplay(PolicyCountryGroupItemLanguage policyCountryGroupItemLanguage) { //Add LanguageName if (policyCountryGroupItemLanguage.LanguageCode != null) { LanguageRepository languageRepository = new LanguageRepository(); Language language = new Language(); language = languageRepository.GetLanguage(policyCountryGroupItemLanguage.LanguageCode); if (language != null) { policyCountryGroupItemLanguage.LanguageName = language.LanguageName; } } //Add PolicyGroupName PolicyCountryGroupItemRepository policyCountryGroupItemRepository = new PolicyCountryGroupItemRepository(); PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(policyCountryGroupItemLanguage.PolicyCountryGroupItemId); if (policyCountryGroupItem != null) { policyCountryGroupItemRepository.EditItemForDisplay(policyCountryGroupItem); policyCountryGroupItemLanguage.PolicyGroupName = policyCountryGroupItem.PolicyGroupName; policyCountryGroupItemLanguage.PolicyGroupId = policyCountryGroupItem.PolicyGroupId; } }
//Delete public void Delete(PolicyCountryGroupItem policyCountryGroupItem) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_DeletePolicyCountryGroupItem_v1( policyCountryGroupItem.PolicyCountryGroupItemId, adminUserGuid, policyCountryGroupItem.VersionNumber ); }
public ActionResult Create(PolicyCountryGroupItemLanguage policyCountryGroupItemLanguage) { PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(policyCountryGroupItemLanguage.PolicyCountryGroupItemId); //Check Exists if (policyCountryGroupItem == null) { ViewData["ActionMethod"] = "CreatePost"; return(View("RecordDoesNotExistError")); } RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { //AccessRights Error return(View("Error")); } //Update Model from Form try { UpdateModel(policyCountryGroupItemLanguage); } 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 { policyCountryGroupItemLanguageRepository.Add(policyCountryGroupItemLanguage); } catch { //Insert Error return(View("Error")); } return(RedirectToAction("List", new { id = policyCountryGroupItem.PolicyCountryGroupItemId })); }
//GET:List public ActionResult List(int id, int?page, string sortField, int?sortOrder) { //Get PolicyCountryGroupItem PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); //Check Exists if (policyCountryGroupItem == null) { ViewData["ActionMethod"] = "ListGet"; return(View("RecordDoesNotExistError")); } //Set Access Rights ViewData["Access"] = ""; RolesRepository rolesRepository = new RolesRepository(); if (rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { ViewData["Access"] = "WriteAccess"; } //Parent Information ViewData["PolicyCountryGroupItemId"] = policyCountryGroupItem.PolicyCountryGroupItemId; ViewData["PolicyGroupID"] = policyCountryGroupItem.PolicyGroupId; ViewData["PolicyGroupName"] = policyGroupRepository.GetGroup(policyCountryGroupItem.PolicyGroupId).PolicyGroupName; //SortField+SortOrder settings if (sortField != "CountryAdvice") { sortField = "LanguageName"; } if (sortOrder == 1) { ViewData["NewSortOrder"] = 0; ViewData["CurrentSortOrder"] = 1; } else { ViewData["NewSortOrder"] = 1; ViewData["CurrentSortOrder"] = 0; sortOrder = 0; } //Get data var cwtPaginatedList = policyCountryGroupItemLanguageRepository.PagePolicyCountryGroupItemCountryAdvice(id, page ?? 1, sortField, sortOrder ?? 0); return(View(cwtPaginatedList)); }
public ActionResult Create(PolicyCountryGroupItem policyCountryGroupItem) { PolicyGroup policyGroup = policyGroupRepository.GetGroup(policyCountryGroupItem.PolicyGroupId); if (policyGroup == null) { ViewData["ActionMethod"] = "CreatePost"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model from Form try { UpdateModel(policyCountryGroupItem); } 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 { policyCountryGroupItemRepository.Add(policyCountryGroupItem); } catch { //Could not insert to database return(View("Error")); } return(RedirectToAction("List", new { id = policyCountryGroupItem.PolicyGroupId })); }
public ActionResult Delete(int id, FormCollection collection) { //Get PolicyCountryGroupItem PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); //Check Exists if (policyCountryGroupItem == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Delete Item try { policyCountryGroupItem.VersionNumber = Int32.Parse(collection["VersionNumber"]); policyCountryGroupItemRepository.Delete(policyCountryGroupItem); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/PolicyCountryGroupItem.mvc/Delete/" + policyCountryGroupItem.PolicyCountryGroupItemId; 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 = policyCountryGroupItem.PolicyGroupId })); }
public ActionResult Delete(int id, string languageCode, FormCollection collection) { //Get Item PolicyCountryGroupItemLanguage policyCountryGroupItemLanguage = new PolicyCountryGroupItemLanguage(); policyCountryGroupItemLanguage = policyCountryGroupItemLanguageRepository.GetItem(id, languageCode); //Check Exists if (policyCountryGroupItemLanguage == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Check AccessRights PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { return(View("Error")); } //Delete Item try { policyCountryGroupItemLanguage.VersionNumber = Int32.Parse(collection["VersionNumber"]); policyCountryGroupItemLanguageRepository.Delete(policyCountryGroupItemLanguage); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/CountryAdvice.mvc/Delete/" + policyCountryGroupItemLanguage.PolicyCountryGroupItemId.ToString() + "/" + policyCountryGroupItemLanguage.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 = policyCountryGroupItemLanguage.PolicyCountryGroupItemId })); }
//Add public void Add(PolicyCountryGroupItem policyCountryGroupItem) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_InsertPolicyCountryGroupItem_v1( policyCountryGroupItem.PolicyCountryStatusId, policyCountryGroupItem.EnabledDate, policyCountryGroupItem.ExpiryDate, policyCountryGroupItem.TravelDateValidFrom, policyCountryGroupItem.TravelDateValidTo, policyCountryGroupItem.EnabledFlag, policyCountryGroupItem.PolicyGroupId, policyCountryGroupItem.CountryCode, policyCountryGroupItem.InheritFromParentFlag, adminUserGuid ); }
// GET: /View public ActionResult View(int id) { //Get PolicyCountryGroupItem PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); //Check Exists if (policyCountryGroupItem == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } //populate new PolicyCountryGroupItem with known PolicyGroup Information policyCountryGroupItemRepository.EditItemForDisplay(policyCountryGroupItem); //Show 'View' Form return(View(policyCountryGroupItem)); }
public ActionResult Edit(int id, FormCollection collection) { PolicyCountryGroupItem policyCountryGroupItem = new PolicyCountryGroupItem(); policyCountryGroupItem = policyCountryGroupItemRepository.GetPolicyCountryGroupItem(id); //Check Exists if (policyCountryGroupItem == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } //Check AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPolicyGroup(policyCountryGroupItem.PolicyGroupId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update PolicyCountryGroupItem Model From Form try { UpdateModel(policyCountryGroupItem); } 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 { policyCountryGroupItemRepository.Update(policyCountryGroupItem); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/PolicyCountryGroupItem.mvc/Edit/" + policyCountryGroupItem.PolicyCountryGroupItemId; 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 to Form return(RedirectToAction("List", new { id = policyCountryGroupItem.PolicyGroupId })); }