// // GET: /ServiceFund/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")); } ServiceFundVM serviceFundVM = new ServiceFundVM(); ServiceFund serviceFund = new ServiceFund(); serviceFundVM.ServiceFund = serviceFund; //GDSs GDSRepository gdsRepository = new GDSRepository(); SelectList gdsList = new SelectList(gdsRepository.GetAllGDSs().ToList(), "GDSCode", "GDSName"); serviceFundVM.GDSs = gdsList; //Countries CountryRepository countryRepository = new CountryRepository(); SelectList countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName"); serviceFundVM.Countries = countries; //Fund Use Statuses FundUseStatusRepository fundUseStatusRepository = new FundUseStatusRepository(); SelectList fundUseStatusList = new SelectList(fundUseStatusRepository.GetAllFundUseStatuses().ToList(), "Key", "Value"); serviceFundVM.FundUseStatuses = fundUseStatusList; //TimeZoneRules TimeZoneRuleRepository timeZoneRuleRepository = new TimeZoneRuleRepository(); SelectList timeZoneRules = new SelectList(timeZoneRuleRepository.GetAllTimeZoneRules().ToList(), "TimeZoneRuleCode", "TimeZoneRuleCodeDesc", "CST/CDT"); serviceFundVM.TimeZoneRules = timeZoneRules; //Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName"); serviceFundVM.Products = products; //Suppliers SupplierRepository supplierRepository = new SupplierRepository(); SelectList suppliers = new SelectList(supplierRepository.GetAllSuppliers().ToList(), "SupplierCode", "SupplierName"); serviceFundVM.Suppliers = suppliers; //Currencies CurrencyRepository currencyRepository = new CurrencyRepository(); SelectList currencies = new SelectList(currencyRepository.GetAllCurrencies().ToList(), "CurrencyCode", "Name"); serviceFundVM.Currencies = currencies; //Service Fund Routings ServiceFundRoutingRepository serviceFundRoutingRepository = new ServiceFundRoutingRepository(); SelectList serviceFundRoutingsList = new SelectList(serviceFundRoutingRepository.GetAllServiceFundRoutings().ToList(), "Key", "Value"); serviceFundVM.ServiceFundRoutings = serviceFundRoutingsList; //ServiceFundChannelTypes ServiceFundChannelTypeRepository serviceFundChannelTypeRepository = new ServiceFundChannelTypeRepository(); SelectList serviceFundChannelTypesList = new SelectList(serviceFundChannelTypeRepository.GetAllServiceFundChannelTypes().ToList(), "ServiceFundChannelTypeId", "ServiceFundChannelTypeName"); serviceFundVM.ServiceFundChannelTypes = serviceFundChannelTypesList; return(View(serviceFundVM)); }
// GET: /ServiceFund/Edit public ActionResult Edit(int id) { //Get Item From Database ServiceFund serviceFund = new ServiceFund(); serviceFund = serviceFundRepository.GetServiceFund(id); //Check Exists if (serviceFund == 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")); } ServiceFundVM serviceFundVM = new ServiceFundVM(); serviceFundVM.ServiceFund = serviceFund; //GDSs GDSRepository gdsRepository = new GDSRepository(); SelectList gdsList = new SelectList(gdsRepository.GetAllGDSs().ToList(), "GDSCode", "GDSName", serviceFund.GDSCode); serviceFundVM.GDSs = gdsList; //Countries CountryRepository countryRepository = new CountryRepository(); SelectList countries = new SelectList(countryRepository.GetAllCountries().ToList(), "CountryCode", "CountryName", serviceFund.PCCCountryCode); serviceFundVM.Countries = countries; //Fund Use Statuses FundUseStatusRepository fundUseStatusRepository = new FundUseStatusRepository(); SelectList fundUseStatusList = new SelectList(fundUseStatusRepository.GetAllFundUseStatuses().ToList(), "Key", "Value", serviceFund.FundUseStatus); serviceFundVM.FundUseStatuses = fundUseStatusList; //TimeZoneRules TimeZoneRuleRepository timeZoneRuleRepository = new TimeZoneRuleRepository(); SelectList timeZoneRules = new SelectList(timeZoneRuleRepository.GetAllTimeZoneRules().ToList(), "TimeZoneRuleCode", "TimeZoneRuleCodeDesc", serviceFund.TimeZoneRuleCode); serviceFundVM.TimeZoneRules = timeZoneRules; //Products ProductRepository productRepository = new ProductRepository(); SelectList products = new SelectList(productRepository.GetAllProducts().ToList(), "ProductId", "ProductName", serviceFund.ProductId); serviceFundVM.Products = products; //Suppliers SupplierRepository supplierRepository = new SupplierRepository(); SelectList suppliers = new SelectList(supplierRepository.GetAllSuppliers().ToList(), "SupplierCode", "SupplierName", serviceFund.SupplierName); serviceFundVM.Suppliers = suppliers; //Currencies CurrencyRepository currencyRepository = new CurrencyRepository(); SelectList currencies = new SelectList(currencyRepository.GetAllCurrencies().ToList(), "CurrencyCode", "Name", serviceFund.ServiceFundCurrencyCode); serviceFundVM.Currencies = currencies; //Service Fund Routings ServiceFundRoutingRepository serviceFundRoutingRepository = new ServiceFundRoutingRepository(); SelectList serviceFundRoutingsList = new SelectList(serviceFundRoutingRepository.GetAllServiceFundRoutings().ToList(), "Key", "Value", serviceFund.ServiceFundRouting); serviceFundVM.ServiceFundRoutings = serviceFundRoutingsList; //ServiceFundChannelTypes ServiceFundChannelTypeRepository serviceFundChannelTypeRepository = new ServiceFundChannelTypeRepository(); SelectList serviceFundChannelTypesList = new SelectList(serviceFundChannelTypeRepository.GetAllServiceFundChannelTypes().ToList(), "ServiceFundChannelTypeId", "ServiceFundChannelTypeName", serviceFund.ServiceFundChannelTypeId); serviceFundVM.ServiceFundChannelTypes = serviceFundChannelTypesList; serviceFundRepository.EditGroupForDisplay(serviceFund); return(View(serviceFundVM)); }