public async Task <IActionResult> OnPostAsync(IFormCollection collection)
        {
            if (FormCollectionAssistant.IsFormButtonSelected("ClearButton", "Clear", collection))
            {
                return(RedirectToPage("/SearchByCode"));
            }

            ViewModel.NAICSCode        = FormCollectionAssistant.GetFormStringValue("ViewModel.NAICSCode", collection);
            ViewModel.NAICSDescription = FormCollectionAssistant.GetFormStringValue("ViewModel.NAICSDescription", collection);

            if (FormCollectionAssistant.IsFormButtonSelected("SearchButton", "Search", collection))
            {
                ViewModel.NAICSDescription = await GetNAICSDescription(ViewModel.NAICSCode);

                if (ViewModel.NAICSDescription == null)
                {
                    ModelState.AddModelError("ErrorMessage", string.Format(CultureInfo.CurrentCulture, "Unable to locate description for given NAICS code: {0}", ViewModel.NAICSCode));

                    ViewModel.NAICSCode = null;

                    return(Page());
                }
            }

            sicDescriptions = await GetSICDescriptions(ViewModel.NAICSCode);

            selectedSICDescription = FormCollectionAssistant.GetFormNumberValue("ViewModel.SelectedSICDescription", collection);

            if (sicDescriptions != null)
            {
                ViewModel.SICDescriptions = new SelectList(sicDescriptions, "Code", "Description");
            }

            if (selectedSICDescription > 0)
            {
                ViewModel.SelectedSICDescription = selectedSICDescription;
            }

            if (selectedSICDescription > 0)
            {
                ViewModel.SICCode = string.Format(CultureInfo.CurrentCulture, "{0000}", selectedSICDescription);
            }

            if (selectedSICDescription > 0)
            {
                ViewModel.SICDescription = GetSICDescription();
            }

            return(Page());
        }
        public async Task <IActionResult> OnPostAsync(IFormCollection collection)
        {
            if (FormCollectionAssistant.IsFormButtonSelected("ClearButton", "Clear", collection))
            {
                return(RedirectToPage("/SearchByKeyword"));
            }

            ViewModel.Keyword = FormCollectionAssistant.GetFormStringValue("ViewModel.Keyword", collection);

            var keywordOption = FormCollectionAssistant.GetFormRadioButtonValue("KeywordOption", collection);

            if (!string.IsNullOrEmpty(keywordOption))
            {
                if (keywordOption.Equals("NAICS"))
                {
                    ViewModel.SearchNAICS = true;
                }
                if (keywordOption.Equals("SIC"))
                {
                    ViewModel.SearchSIC = true;
                }
            }
            if (ViewModel.SearchNAICS == false && ViewModel.SearchSIC == false)
            {
                ViewModel.SearchNAICS = true;
            }

            ViewModel.KeywordOption = ViewModel.SearchNAICS ? "NAICS" : "SIC";

            if (!string.IsNullOrEmpty(ViewModel.Keyword))
            {
                ViewModel.SearchResults = await FindByKeyword(ViewModel.Keyword, ViewModel.SearchNAICS);
            }

            return(Page());
        }