public ActionResult Delete(int id) { //Get Item From Database PointOfSaleFeeLoad pointOfSaleFeeLoad = new PointOfSaleFeeLoad(); pointOfSaleFeeLoad = pointOfSaleFeeLoadRepository.GetGroup(id); //Check Exists if (pointOfSaleFeeLoad == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } PointOfSaleFeeLoadVM pointOfSaleFeeLoadVM = new PointOfSaleFeeLoadVM(); pointOfSaleFeeLoadRepository.EditGroupForDisplay(pointOfSaleFeeLoad); pointOfSaleFeeLoadVM.PointOfSaleFeeLoad = pointOfSaleFeeLoad; return(View(pointOfSaleFeeLoadVM)); }
// GET: /Edit public ActionResult Edit(int id) { //Get Item From Database PointOfSaleFeeLoad pointOfSaleFeeLoad = new PointOfSaleFeeLoad(); pointOfSaleFeeLoad = pointOfSaleFeeLoadRepository.GetGroup(id); //Check Exists if (pointOfSaleFeeLoad == null) { ViewData["ActionMethod"] = "EditGet"; return(View("RecordDoesNotExistError")); } //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } PointOfSaleFeeLoadVM pointOfSaleFeeLoadVM = new PointOfSaleFeeLoadVM(); pointOfSaleFeeLoadRepository.EditGroupForDisplay(pointOfSaleFeeLoad); pointOfSaleFeeLoadVM.PointOfSaleFeeLoad = pointOfSaleFeeLoad; //FeeLoadDescriptionTypeCodes FeeLoadDescriptionTypeCodeRepository feeLoadDescriptionTypeCodeRepository = new FeeLoadDescriptionTypeCodeRepository(); SelectList feeLoadDescriptionTypeCodes = new SelectList(feeLoadDescriptionTypeCodeRepository.GetAllFeeLoadDescriptionTypeCodes().ToList(), "FeeLoadDescriptionTypeCode", "FeeLoadDescriptionTypeCode", pointOfSaleFeeLoad.FeeLoadDescriptionTypeCode); pointOfSaleFeeLoadVM.FeeLoadDescriptionTypeCodes = feeLoadDescriptionTypeCodes; //Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName", pointOfSaleFeeLoad.ProductId); pointOfSaleFeeLoadVM.Products = products; //TravelIndicators TravelIndicatorRepository TravelIndicatorRepository = new TravelIndicatorRepository(); SelectList travelIndicators = new SelectList(TravelIndicatorRepository.GetAllTravelIndicators().OrderBy(x => x.TravelIndicatorDescription).ToList(), "TravelIndicator1", "TravelIndicatorDescription", pointOfSaleFeeLoad.TravelIndicator); pointOfSaleFeeLoadVM.TravelIndicators = travelIndicators; //Currencies CurrencyRepository currencyRepository = new CurrencyRepository(); SelectList currencies = new SelectList(currencyRepository.GetAllCurrencies().ToList(), "CurrencyCode", "Name", pointOfSaleFeeLoad.FeeLoadCurrencyCode); pointOfSaleFeeLoadVM.Currencies = currencies; return(View(pointOfSaleFeeLoadVM)); }
public ActionResult Delete(PointOfSaleFeeLoadVM pointOfSaleFeeLoadVM) { //Check Valid Item passed in Form if (pointOfSaleFeeLoadVM.PointOfSaleFeeLoad == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Get Item From Database PointOfSaleFeeLoad pointOfSaleFeeLoad = new PointOfSaleFeeLoad(); pointOfSaleFeeLoad = pointOfSaleFeeLoadRepository.GetGroup(pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.PointOfSaleFeeLoadId); //Check Exists in Databsase if (pointOfSaleFeeLoad == null) { ViewData["ActionMethod"] = "DeletePost"; return(View("RecordDoesNotExistError")); } //Check Access RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPointOfSaleFeeLoad(pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.PointOfSaleFeeLoadId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Delete Form Item try { pointOfSaleFeeLoadRepository.Delete(pointOfSaleFeeLoadVM.PointOfSaleFeeLoad); } catch (SqlException ex) { //Versioning Error - go to standard versionError page if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/PointOfSaleFeeLoad.mvc/Delete/" + pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.PointOfSaleFeeLoadId; 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")); }
//Add Group public void Add(PointOfSaleFeeLoadVM pointOfSaleFeeLoadVM) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_InsertPointOfSaleFeeLoad_v1( pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.ClientTopUnitGuid, pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.ClientSubUnitGuid, pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.TravelerTypeGuid, pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.FeeLoadDescriptionTypeCode, pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.ProductId, pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.AgentInitiatedFlag, pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.TravelIndicator, pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.FeeLoadAmount, pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.FeeLoadCurrencyCode, adminUserGuid ); }
// GET: /Create public ActionResult Create() { //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } PointOfSaleFeeLoadVM pointOfSaleFeeLoadVM = new PointOfSaleFeeLoadVM(); //AgentInitiatedFlag Default Checked PointOfSaleFeeLoad pointOfSaleFeeLoad = new PointOfSaleFeeLoad(); pointOfSaleFeeLoad.AgentInitiatedFlag = true; pointOfSaleFeeLoadVM.PointOfSaleFeeLoad = pointOfSaleFeeLoad; //FeeLoadDescriptionTypeCodes FeeLoadDescriptionTypeCodeRepository feeLoadDescriptionTypeCodeRepository = new FeeLoadDescriptionTypeCodeRepository(); SelectList feeLoadDescriptionTypeCodes = new SelectList(feeLoadDescriptionTypeCodeRepository.GetAllFeeLoadDescriptionTypeCodes().ToList(), "FeeLoadDescriptionTypeCode", "FeeLoadDescriptionTypeCode"); pointOfSaleFeeLoadVM.FeeLoadDescriptionTypeCodes = feeLoadDescriptionTypeCodes; //Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName"); pointOfSaleFeeLoadVM.Products = products; //TravelIndicators TravelIndicatorRepository TravelIndicatorRepository = new TravelIndicatorRepository(); SelectList travelIndicators = new SelectList(TravelIndicatorRepository.GetAllTravelIndicators().OrderBy(x => x.TravelIndicatorDescription).ToList(), "TravelIndicator1", "TravelIndicatorDescription"); pointOfSaleFeeLoadVM.TravelIndicators = travelIndicators; //Currencies CurrencyRepository currencyRepository = new CurrencyRepository(); SelectList currencies = new SelectList(currencyRepository.GetAllCurrencies().ToList(), "CurrencyCode", "Name"); pointOfSaleFeeLoadVM.Currencies = currencies; return(View(pointOfSaleFeeLoadVM)); }
public ActionResult Edit(PointOfSaleFeeLoadVM pointOfSaleFeeLoadVM, FormCollection formCollection) { //Get Item PointOfSaleFeeLoad pointOfSaleFeeLoad = new PointOfSaleFeeLoad(); pointOfSaleFeeLoad = pointOfSaleFeeLoadRepository.GetGroup(pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.PointOfSaleFeeLoadId); //Check Exists if (pointOfSaleFeeLoad == null) { ViewData["ActionMethod"] = "EditPost"; return(View("RecordDoesNotExistError")); } //Check Access Rights RolesRepository rolesRepository = new RolesRepository(); if (!rolesRepository.HasWriteAccessToPointOfSaleFeeLoad(pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.PointOfSaleFeeLoadId)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //Update Model From Form + Validate against DB try { UpdateModel <PointOfSaleFeeLoad>(pointOfSaleFeeLoadVM.PointOfSaleFeeLoad, "PointOfSaleFeeLoad"); } 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 { pointOfSaleFeeLoadRepository.Edit(pointOfSaleFeeLoadVM); } catch (SqlException ex) { //Versioning Error if (ex.Message == "SQLVersioningError") { ViewData["ReturnURL"] = "/PointOfSaleFeeLoad.mvc/Edit/" + pointOfSaleFeeLoadVM.PointOfSaleFeeLoad.PointOfSaleFeeLoadId; 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")); }
public ActionResult Create(PointOfSaleFeeLoadVM pointOfSaleFeeLoadVM, FormCollection formCollection) { //Check Access Rights to Domain if (!hierarchyRepository.AdminHasDomainWriteAccess(groupName)) { ViewData["Message"] = "You do not have access to this item"; return(View("Error")); } //We need to extract group from groupVM PointOfSaleFeeLoad pointOfSaleFeeLoad = new PointOfSaleFeeLoad(); pointOfSaleFeeLoad = pointOfSaleFeeLoadVM.PointOfSaleFeeLoad; if (pointOfSaleFeeLoad == null) { ViewData["Message"] = "ValidationError : missing item";; return(View("Error")); } //Update Model From Form + Validate against DB try { UpdateModel <PointOfSaleFeeLoad>(pointOfSaleFeeLoad, "PointOfSaleFeeLoad"); } 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 { pointOfSaleFeeLoadRepository.Add(pointOfSaleFeeLoadVM); } 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")); }