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)); }
// 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)); }
//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; } }
//Add to DB public void Add(PolicyCityGroupItemLanguage policyCityGroupItemLanguage) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_InsertPolicyCityGroupItemCityAdvice_v1( policyCityGroupItemLanguage.PolicyCityGroupItemId, policyCityGroupItemLanguage.LanguageCode, policyCityGroupItemLanguage.CityAdvice, adminUserGuid ); }
//Delete From DB public void Delete(PolicyCityGroupItemLanguage policyCityGroupItemLanguage) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_DeletePolicyCityGroupItemCityAdvice_v1( policyCityGroupItemLanguage.PolicyCityGroupItemId, policyCityGroupItemLanguage.LanguageCode, adminUserGuid, policyCityGroupItemLanguage.VersionNumber ); }
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 })); }
//GET: View public ActionResult View(int id, string languageCode) { PolicyCityGroupItemLanguage policyCityGroupItemLanguage = new PolicyCityGroupItemLanguage(); policyCityGroupItemLanguage = policyCityGroupItemLanguageRepository.GetItem(id, languageCode); if (policyCityGroupItemLanguage == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } policyCityGroupItemLanguageRepository.EditItemForDisplay(policyCityGroupItemLanguage); return(View(policyCityGroupItemLanguage)); }
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 })); }
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 })); }