private void SetSelectByKeywordSessionVariables(SearchByKeywordViewModel model) { Session["Keyword"] = model.Keyword; Session["KeywordSearchResults"] = model.SearchResults; Session["KeywordSearchByNAICS"] = model.SearchNAICS; Session["KeywordSearchBySIC"] = model.SearchSIC; }
private static void SetSearchedValues(SearchByKeywordViewModel model, FormCollection collection, bool optionOnly) { if (!optionOnly) { model.Keyword = FormCollectionHelper.GetFormStringValue("Keyword", collection); } var keywordOption = FormCollectionHelper.GetFormRadioButtonValue("KeywordOption", collection); if (!string.IsNullOrEmpty(keywordOption)) { if (keywordOption.Equals("NAICS")) { model.SearchNAICS = true; } if (keywordOption.Equals("SIC")) { model.SearchSIC = true; } } if (model.SearchNAICS == false && model.SearchSIC == false) { model.SearchNAICS = true; } }
public async Task <IActionResult> OnGetKeywordAsync(string keyword, string option) { ViewModel = new SearchByKeywordViewModel { SearchResults = new List <ClassificationCodes>() }; if (!string.IsNullOrEmpty(keyword)) { ViewModel.Keyword = keyword; ViewModel.KeywordOption = option; if (!string.IsNullOrEmpty(option)) { if (option.Equals("NAICS")) { ViewModel.SearchNAICS = true; } if (option.Equals("SIC")) { ViewModel.SearchSIC = true; } } ViewModel.SearchResults = await FindByKeyword(ViewModel.Keyword, ViewModel.SearchNAICS); } return(Page()); }
public IActionResult OnGet() { ViewModel = new SearchByKeywordViewModel { SearchResults = new List <ClassificationCodes>(), SearchNAICS = true }; return(Page()); }
private void GetSelectByKeywordSessionVariables(SearchByKeywordViewModel model) { if (Session["Keyword"] != null) { model.Keyword = (string)Session["Keyword"]; } if (Session["KeywordSearchResults"] != null) { model.SearchResults = (List <ClassificationCode>)Session["KeywordSearchResults"]; } if (Session["KeywordSearchByNAICS"] != null) { model.SearchNAICS = (bool)Session["KeywordSearchByNAICS"]; } if (Session["KeywordSearchBySIC"] != null) { model.SearchSIC = (bool)Session["KeywordSearchBySIC"]; } }
public async Task <ActionResult> SearchByKeyword(FormCollection collection, bool?useCache) { var model = new SearchByKeywordViewModel(); var clear = FormCollectionHelper.IsFormButtonSelected("ClearButton", "Clear", collection); if (useCache != null && useCache == true) { GetSelectByKeywordSessionVariables(model); return(View(model)); } RemoveSelectByKeywordSessionVariables(); if (clear) { SetSearchedValues(model, collection, true); return(View(model)); } using (var context = new IndustryCodesContext()) { SetSearchedValues(model, collection, false); if (!string.IsNullOrEmpty(model.Keyword)) { model.SearchResults = await FindByKeyword(context, model.Keyword, model.SearchNAICS); } SetSelectByKeywordSessionVariables(model); } return(View(model)); }