Beispiel #1
0
        public async Task <IActionResult> OnGet()
        {
            ViewModel = new SearchBySelectionViewModel();

            selectedIndustrySector    = 0;
            selectedIndustrySubsector = 0;
            selectedNAICSDescription  = 0;
            selectedSICDescription    = 0;

            industrySectors = await GetIndustrySectors();

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

            ViewModel.IndustrySubsectors        = new SelectList(new Collection <IndustrySubsector>(), "Code", "Description");
            ViewModel.SelectedIndustrySubsector = 0;

            ViewModel.NAICSDescriptions        = new SelectList(new Collection <NAICSDescription>(), "Code", "Description");
            ViewModel.SelectedNAICSDescription = 0;

            sicDescriptions = await GetSICDescriptions(null);

            ViewModel.SICDescriptions        = new SelectList(new Collection <SICDescription>(), "Code", "Description");
            ViewModel.SelectedSICDescription = 0;

            SetSessionVariables();

            return(Page());
        }
Beispiel #2
0
        public async Task <ActionResult> SearchBySelection(FormCollection collection)
        {
            var model = new SearchBySelectionViewModel();

            using (var context = new IndustryCodesContext())
            {
                if (FormCollectionHelper.IsFormButtonSelected("ClearButton", "Clear", collection))
                {
                    industrySectors = await GetIndustrySectors(context);

                    model.IndustrySectors        = new SelectList(industrySectors, "Code", "Description");
                    model.SelectedIndustrySector = 0;

                    model.IndustrySubsectors        = new SelectList(new Collection <IndustrySubsector>(), "Code", "Description");
                    model.SelectedIndustrySubsector = 0;

                    model.NAICSDescriptions        = new SelectList(new Collection <NAICSDescription>(), "Code", "Description");
                    model.SelectedNAICSDescription = 0;

                    sicDescriptions = await GetSICDescriptions(context, null);

                    model.SICDescriptions        = new SelectList(new Collection <SICDescription>(), "Code", "Description");
                    model.SelectedSICDescription = 0;

                    SetSelectionSessionVariables();

                    return(View(model));
                }

                GetSelectionSessionVariables();

                industrySectors = await GetIndustrySectors(context);

                selectedIndustrySector = FormCollectionHelper.GetFormNumberValue("SelectedIndustrySector", collection);

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

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

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

                    naicsDescriptions = await GetNAICSDescriptions(context);

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

                    sicDescriptions = await GetSICDescriptions(context, null);

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

                    SetSelectionSessionVariables();

                    return(View(model));
                }

                industrySubsectors = await GetIndustrySubsectors(context);

                selectedIndustrySubsector = FormCollectionHelper.GetFormNumberValue("SelectedIndustrySubsector", collection);

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

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

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

                    sicDescriptions = await GetSICDescriptions(context, null);

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

                    SetSelectionSessionVariables();

                    return(View(model));
                }

                naicsDescriptions = await GetNAICSDescriptions(context);

                selectedNAICSDescription = FormCollectionHelper.GetFormNumberValue("SelectedNAICSDescription", collection);

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

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

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

                    SetSelectionSessionVariables();

                    return(View(model));
                }

                sicDescriptions = await GetSICDescriptions(context, null);

                selectedSICDescription = FormCollectionHelper.GetFormNumberValue("SelectedSICDescription", collection);

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

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

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

                SetSelectionSessionVariables();
            }

            return(View(model));
        }