//Add Data From Linked Tables for Display public void EditForDisplay(FareRestriction fareRestriction) { //Add LanguageName if (fareRestriction.LanguageCode != null) { LanguageRepository languageRepository = new LanguageRepository(); Language language = new Language(); language = languageRepository.GetLanguage(fareRestriction.LanguageCode); if (language != null) { fareRestriction.LanguageName = language.LanguageName; } } ProductRepository productRepository = new ProductRepository(); Product product = new Product(); product = productRepository.GetProduct(fareRestriction.ProductId); if (product != null) { fareRestriction.ProductName = product.ProductName; } SupplierRepository supplierRepository = new SupplierRepository(); Supplier supplier = new Supplier(); supplier = supplierRepository.GetSupplier(fareRestriction.SupplierCode, fareRestriction.ProductId); if (supplier != null) { fareRestriction.SupplierName = supplier.SupplierName; } }
// GET: /View public ActionResult View(int id) { //Check Exists FareRestriction fareRestriction = new FareRestriction(); fareRestriction = fareRestrictionRepository.GetFareRestriction(id); if (fareRestriction == null) { ViewData["ActionMethod"] = "ViewGet"; return(View("RecordDoesNotExistError")); } fareRestrictionRepository.EditForDisplay(fareRestriction); //add the PolicyRouting information PolicyRouting policyRouting = new PolicyRouting(); if (fareRestriction.RoutingId != null) { policyRouting = policyRoutingRepository.GetPolicyRouting((int)fareRestriction.RoutingId); policyRoutingRepository.EditForDisplay(policyRouting); } FareRestrictionViewModel fareRestrictionViewModel = new FareRestrictionViewModel(fareRestriction, policyRouting); //Show View return(View(fareRestrictionViewModel)); }
// GET: /CreatePolicyRouting public ActionResult CreatePolicyRouting(int id) { //Get PolicyAirVendorGroupItem FareRestriction fareRestriction = new FareRestriction(); fareRestriction = fareRestrictionRepository.GetFareRestriction(id); //Check Exists if (fareRestriction == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToReferenceInfo()) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //populate new PolicyAirVendorGroupItem with known PolicyGroup Information fareRestrictionRepository.EditForDisplay(fareRestriction); PolicyRouting policyRouting = new PolicyRouting(); FareRestrictionViewModel fareRestrictionViewModel = new FareRestrictionViewModel(fareRestriction, policyRouting); //Show 'Create' Form return(View(fareRestrictionViewModel)); }
//Delete From DB public void Delete(FareRestriction fareRestriction) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_DeleteFareRestriction_v1( fareRestriction.FareRestrictionId, adminUserGuid, fareRestriction.VersionNumber ); }
public ActionResult Edit(FareRestrictionViewModel fareRestrictionViewModel) { //Get PolicyRouting Info PolicyRouting policyRouting = new PolicyRouting(); policyRouting = fareRestrictionViewModel.PolicyRouting; policyRoutingRepository.EditPolicyRouting(policyRouting); FareRestriction fareRestriction = new FareRestriction(); fareRestriction = fareRestrictionRepository.GetFareRestriction(fareRestrictionViewModel.FareRestriction.FareRestrictionId); //Check Exists if (fareRestriction == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToReferenceInfo()) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } try{ fareRestrictionRepository.Update(fareRestriction, policyRouting); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/FareRestriction.mvc/Edit/" + fareRestriction.FareRestrictionId.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")); } //Success return(RedirectToAction("List")); }
public ActionResult Create(FareRestrictionViewModel fareRestrictionViewModel, string btnSubmit) { //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToReferenceInfo()) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Get PolicyRouting Info PolicyRouting policyRouting = new PolicyRouting(); policyRouting = fareRestrictionViewModel.PolicyRouting; //Get PolicyAirVendorGroupItem Info FareRestriction fareRestriction = new FareRestriction(); fareRestriction = fareRestrictionViewModel.FareRestriction; //Edit Routing policyRoutingRepository.EditPolicyRouting(policyRouting); try { fareRestrictionRepository.Add(fareRestriction, 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 switch (btnSubmit) { case "Save": return(RedirectToAction("List")); default: return(RedirectToAction("CreatePolicyRouting", new { id = fareRestriction.FareRestrictionId })); } }
// GET: /Edit public ActionResult Edit(int id) { //Check Exists FareRestriction fareRestriction = new FareRestriction(); fareRestriction = fareRestrictionRepository.GetFareRestriction(id); if (fareRestriction == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToReferenceInfo()) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Populate List of Languages LanguageRepository languageRepository = new LanguageRepository(); SelectList languages = new SelectList(languageRepository.GetAllLanguages().ToList(), "LanguageCode", "LanguageName"); ViewData["LanguageList"] = languages; //Populate List of Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName"); ViewData["ProductList"] = products; fareRestrictionRepository.EditForDisplay(fareRestriction); //add the PolicyRouting information PolicyRouting policyRouting = new PolicyRouting(); if (fareRestriction.RoutingId != null) { policyRouting = policyRoutingRepository.GetPolicyRouting((int)fareRestriction.RoutingId); policyRoutingRepository.EditPolicyRouting(policyRouting); } FareRestrictionViewModel fareRestrictionViewModel = new FareRestrictionViewModel(fareRestriction, policyRouting); return(View(fareRestrictionViewModel)); }
public ActionResult Delete(int id, FormCollection collection) { //Check Exists FareRestriction fareRestriction = new FareRestriction(); fareRestriction = fareRestrictionRepository.GetFareRestriction(id); if (fareRestriction == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToReferenceInfo()) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Delete Item try { fareRestriction.VersionNumber = Int32.Parse(collection["VersionNumber"]); fareRestrictionRepository.Delete(fareRestriction); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/FareRestriction.mvc/Delete/" + fareRestriction.FareRestrictionId.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(RedirectToAction("List")); }
// GET: /Create public ActionResult Create() { FareRestriction fareRestriction = new FareRestriction(); //Check Exists if (fareRestriction == null) { ViewData["ActionMethod"] = "CreateGet"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToReferenceInfo()) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Populate List of Languages LanguageRepository languageRepository = new LanguageRepository(); SelectList languages = new SelectList(languageRepository.GetAllLanguages().ToList(), "LanguageCode", "LanguageName"); ViewData["LanguageList"] = languages; //Populate List of Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName"); ViewData["ProductList"] = products; PolicyRouting policyRouting = new PolicyRouting(); policyRouting.FromGlobalFlag = false; policyRouting.ToGlobalFlag = false; FareRestrictionViewModel fareRestrictionViewModel = new FareRestrictionViewModel(fareRestriction, policyRouting); //Show 'Create' Form return(View(fareRestrictionViewModel)); }
//Add to DB public void Add(FareRestriction fareRestriction, PolicyRouting policyRouting) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; int? fareRestrictionId = new Int32(); db.spDesktopDataAdmin_InsertFareRestriction_v1( ref fareRestrictionId, fareRestriction.Changes, fareRestriction.Cancellations, fareRestriction.ReRoute, fareRestriction.ValidOn, fareRestriction.MinimumStay, fareRestriction.MaximumStay, fareRestriction.FareBasis, fareRestriction.BookingClass, fareRestriction.SupplierCode, fareRestriction.ProductId, fareRestriction.LanguageCode, fareRestriction.DefaultChecked, policyRouting.Name, policyRouting.FromGlobalFlag, policyRouting.FromGlobalRegionCode, policyRouting.FromGlobalSubRegionCode, policyRouting.FromCountryCode, policyRouting.FromCityCode, policyRouting.FromTravelPortCode, policyRouting.FromTraverlPortTypeId, policyRouting.ToGlobalFlag, policyRouting.ToGlobalRegionCode, policyRouting.ToGlobalSubRegionCode, policyRouting.ToCountryCode, policyRouting.ToCityCode, policyRouting.ToTravelPortCode, policyRouting.ToTravelPortTypeId, policyRouting.RoutingViceVersaFlag, adminUserGuid ); fareRestriction.FareRestrictionId = (int)fareRestrictionId; }
public ActionResult Delete(int id) { //Check Exists FareRestriction fareRestriction = new FareRestriction(); fareRestriction = fareRestrictionRepository.GetFareRestriction(id); if (fareRestriction == null) { ViewData["ActionMethod"] = "DeleteGet"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToReferenceInfo()) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //EditForDisplay fareRestrictionRepository.EditForDisplay(fareRestriction); //add the PolicyRouting information PolicyRouting policyRouting = new PolicyRouting(); if (fareRestriction.RoutingId != null) { policyRouting = policyRoutingRepository.GetPolicyRouting((int)fareRestriction.RoutingId); policyRoutingRepository.EditForDisplay(policyRouting); } FareRestrictionViewModel fareRestrictionViewModel = new FareRestrictionViewModel(fareRestriction, policyRouting); //Show 'Create' Form return(View(fareRestrictionViewModel)); }
public FareRestrictionViewModel(FareRestriction fareRestriction, PolicyRouting policyRouting) { FareRestriction = fareRestriction; PolicyRouting = policyRouting; }
public ActionResult CreatePolicyRouting(int id, PolicyRouting policyRouting, string btnSubmit) { //Get PolicyAirVendorGroupItem (Original) FareRestriction fareRestrictionOriginal = new FareRestriction(); fareRestrictionOriginal = fareRestrictionRepository.GetFareRestriction(id); //Check Exists if (fareRestrictionOriginal == null) { ViewData["ActionMethod"] = "CreatePost"; return(View("RecordDoesNotExistError")); } //AccessRights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToReferenceInfo()) { 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 fareRestriction from original FareRestriction fareRestriction = new FareRestriction(); fareRestriction.Changes = fareRestrictionOriginal.Changes; fareRestriction.Cancellations = fareRestrictionOriginal.Cancellations; fareRestriction.ReRoute = fareRestrictionOriginal.ReRoute; fareRestriction.ValidOn = fareRestrictionOriginal.ValidOn; fareRestriction.MinimumStay = fareRestrictionOriginal.MinimumStay; fareRestriction.MaximumStay = fareRestrictionOriginal.MaximumStay; fareRestriction.FareBasis = fareRestrictionOriginal.FareBasis; fareRestriction.BookingClass = fareRestrictionOriginal.BookingClass; fareRestriction.ProductId = fareRestrictionOriginal.ProductId; fareRestriction.SupplierCode = fareRestrictionOriginal.SupplierCode; fareRestriction.LanguageCode = fareRestrictionOriginal.LanguageCode; fareRestriction.DefaultChecked = fareRestrictionOriginal.DefaultChecked; //Save policyAirVendorGroupItem to DB try { fareRestrictionRepository.Add(fareRestriction, 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 switch (btnSubmit) { case "Save": return(RedirectToAction("List")); default: return(RedirectToAction("CreatePolicyRouting", new { id = id })); } }