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 Data From Linked Tables for Display public void EditGroupForDisplay(PointOfSaleFeeLoad pointOfSaleFeeLoad) { //ClientTopUnit if (pointOfSaleFeeLoad.ClientTopUnitGuid != null) { ClientTopUnitRepository ClientTopUnitRepository = new ClientTopUnitRepository(); ClientTopUnit clientTopUnit = ClientTopUnitRepository.GetClientTopUnit(pointOfSaleFeeLoad.ClientTopUnitGuid); if (clientTopUnit != null) { pointOfSaleFeeLoad.ClientTopUnitName = clientTopUnit.ClientTopUnitName; } } //ClientSubUnit if (pointOfSaleFeeLoad.ClientSubUnitGuid != null) { ClientSubUnitRepository ClientSubUnitRepository = new ClientSubUnitRepository(); ClientSubUnit clientSubUnit = ClientSubUnitRepository.GetClientSubUnit(pointOfSaleFeeLoad.ClientSubUnitGuid); if (clientSubUnit != null) { pointOfSaleFeeLoad.ClientSubUnitName = clientSubUnit.ClientSubUnitName; } } //TravelerType if (pointOfSaleFeeLoad.TravelerTypeGuid != null) { TravelerTypeRepository TravelerTypeRepository = new TravelerTypeRepository(); TravelerType TravelerType = TravelerTypeRepository.GetTravelerType(pointOfSaleFeeLoad.TravelerTypeGuid); if (TravelerType != null) { pointOfSaleFeeLoad.TravelerTypeName = TravelerType.TravelerTypeName; } } //Product if (pointOfSaleFeeLoad.ProductId > 0) { ProductRepository productRepository = new ProductRepository(); Product product = productRepository.GetProduct(pointOfSaleFeeLoad.ProductId); if (product != null) { pointOfSaleFeeLoad.Product = product; } } }
//Delete From DB public void Delete(PointOfSaleFeeLoad pointOfSaleFeeLoad) { string adminUserGuid = HttpContext.Current.User.Identity.Name.Split(new[] { '|' })[0]; db.spDesktopDataAdmin_DeletePointOfSaleFeeLoad_v1( pointOfSaleFeeLoad.PointOfSaleFeeLoadId, pointOfSaleFeeLoad.ClientTopUnitGuid, pointOfSaleFeeLoad.ClientSubUnitGuid, pointOfSaleFeeLoad.TravelerTypeGuid, pointOfSaleFeeLoad.FeeLoadDescriptionTypeCode, pointOfSaleFeeLoad.ProductId, pointOfSaleFeeLoad.AgentInitiatedFlag, pointOfSaleFeeLoad.TravelIndicator, adminUserGuid, pointOfSaleFeeLoad.VersionNumber ); }
// 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 PointOfSaleFeeLoadVM( PointOfSaleFeeLoad pointOfSaleFeeLoad ) { PointOfSaleFeeLoad = pointOfSaleFeeLoad; }
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")); }