public ActionResult JobTypeFrontEnd(string Slug) { WebsiteViewModel vm = _GetViewModel(Slug); vm.BrainTreeToken = _BrainTreeService.CreateToken(); vm.Website = WebsiteService.websiteGetBySlug(Slug); return(View(vm)); }
//get viewmodel function created for majority of logic needed to inject website view model with appropriate data private WebsiteViewModel _GetViewModel(string Slug) { //null check on slug, if null load bringpro website by default //added for the azure hosted version if (Slug == null) { Slug = "bringpro"; } //instantiate new instance of website view model WebsiteViewModel vm = new WebsiteViewModel(); vm.Slug = Slug; // add website slug to view model vm.CategoryEnum = SettingsCategory.String; //adding enums to the viewmodel vm.SettingTypeEnum = SettingsType.Design; vm.SettingSectionEnum = SettingsSection.Layout; WebsiteSettingsServices websiteService = new WebsiteSettingsServices(); // instantiate a new instance of website settings service //generate a new list of website settings - populated by service that loads settings by website slug List <WebsiteSettings> WebsiteBySlug = websiteService.GetSettingsBySlug(Slug); vm.Settings = WebsiteBySlug; if (vm.Settings.Count < 1 && Slug != "backoffice") { throw new HttpException(404, "Website Does Not Exist"); } //if website exists - load a model of website if (Slug != null && Slug != "") { vm.Website = WebsiteService.websiteGetBySlug(Slug); } //returning the viewmodel after populating with website settings model and website model // both have different fields of data return(vm); }