public IActionResult OnPost(IFormCollection collection)
        {
            if (FormCollectionAssistant.IsFormButtonSelected("BackButton", "Back", collection))
            {
                return(RedirectToPage("/SearchByKeyword", "Keyword", new { keyword = ViewModel.Keyword, option = ViewModel.KeywordOption }));
            }

            return(Page());
        }
        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());
        }
Example #4
0
        public async Task <IActionResult> OnPostAsync(IFormCollection collection)
        {
            if (FormCollectionAssistant.IsFormButtonSelected("ClearButton", "Clear", collection))
            {
                return(RedirectToPage("/SearchBySelection"));
            }

            GetSessionVariables();

            industrySectors = await GetIndustrySectors();

            selectedIndustrySector = FormCollectionAssistant.GetFormNumberValue("ViewModel.SelectedIndustrySector", collection);

            ViewModel.IndustrySectors        = new SelectList(industrySectors, "Code", "Description");
            ViewModel.SelectedIndustrySector = selectedIndustrySector;

            if (selectedIndustrySector != previousSelectedIndustrySector)
            {
                industrySubsectors = await GetIndustrySubsectors();

                ViewModel.IndustrySubsectors        = new SelectList(industrySubsectors, "Code", "Description");
                ViewModel.SelectedIndustrySubsector = selectedIndustrySubsector;

                naicsDescriptions = await GetNAICSDescriptions();

                ViewModel.NAICSDescriptions        = new SelectList(naicsDescriptions, "Code", "Description");
                ViewModel.SelectedNAICSDescription = selectedNAICSDescription;

                sicDescriptions = await GetSICDescriptions(null);

                ViewModel.SICDescriptions        = new SelectList(sicDescriptions, "Code", "Description");
                ViewModel.SelectedSICDescription = selectedSICDescription;

                SetSessionVariables();

                return(Page());
            }

            industrySubsectors = await GetIndustrySubsectors();

            selectedIndustrySubsector = FormCollectionAssistant.GetFormNumberValue("ViewModel.SelectedIndustrySubsector", collection);

            ViewModel.IndustrySubsectors        = new SelectList(industrySubsectors, "Code", "Description");
            ViewModel.SelectedIndustrySubsector = selectedIndustrySubsector;

            if (selectedIndustrySubsector != previousSelectedIndustrySubsector)
            {
                naicsDescriptions = await GetNAICSDescriptions();

                ViewModel.NAICSDescriptions        = new SelectList(naicsDescriptions, "Code", "Description");
                ViewModel.SelectedNAICSDescription = selectedNAICSDescription;

                sicDescriptions = await GetSICDescriptions(null);

                ViewModel.SICDescriptions        = new SelectList(sicDescriptions, "Code", "Description");
                ViewModel.SelectedSICDescription = selectedSICDescription;

                SetSessionVariables();

                return(Page());
            }

            naicsDescriptions = await GetNAICSDescriptions();

            selectedNAICSDescription = FormCollectionAssistant.GetFormNumberValue("ViewModel.SelectedNAICSDescription", collection);

            ViewModel.NAICSDescriptions        = new SelectList(naicsDescriptions, "Code", "Description");
            ViewModel.SelectedNAICSDescription = selectedNAICSDescription;

            if (selectedNAICSDescription != previousSelectedNAICSDescription)
            {
                sicDescriptions = await GetSICDescriptions(null);

                ViewModel.SICDescriptions        = new SelectList(sicDescriptions, "Code", "Description");
                ViewModel.SelectedSICDescription = selectedSICDescription;

                SetSessionVariables();

                return(Page());
            }

            sicDescriptions = await GetSICDescriptions(null);

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

            ViewModel.SICDescriptions        = new SelectList(sicDescriptions, "Code", "Description");
            ViewModel.SelectedSICDescription = selectedSICDescription;

            if (selectedNAICSDescription > 0 || selectedSICDescription > 0)
            {
                ViewModel.NAICSCode        = string.Format(CultureInfo.CurrentCulture, "{000000}", selectedNAICSDescription);
                ViewModel.NAICSDescription = await GetNAICSDescription(ViewModel.NAICSCode);

                ViewModel.SICCode        = string.Format(CultureInfo.CurrentCulture, "{0000}", selectedSICDescription);
                ViewModel.SICDescription = await GetSICDescription(ViewModel.NAICSCode);
            }

            SetSessionVariables();

            return(Page());
        }