private PsfModel GetCurrentPageFilter()
        {
            var savedSection    = preSearchFilterStateManager.GetSavedSection(SectionTitle, FilterType);
            var restoredSection = preSearchFilterStateManager.RestoreOptions(savedSection, GetFilterOptions());

            //create the section for this page
            var currentSection = autoMapper.Map <PsfSection>(restoredSection);
            var filterSection  = currentSection ?? new PsfSection();

            filterSection.Name               = SectionTitle;
            filterSection.Description        = SectionDescription;
            filterSection.SingleSelectOnly   = SingleSelectOnly;
            filterSection.NextPageUrl        = NextPageUrl;
            filterSection.PreviousPageUrl    = PreviousPageUrl;
            filterSection.PageNumber         = ThisPageNumber;
            filterSection.TotalNumberOfPages = TotalNumberOfPages;
            filterSection.SectionDataType    = FilterType.ToString();

            var thisPageModel = new PsfModel
            {
                //Throw the state out again
                OptionsSelected = preSearchFilterStateManager.GetStateJson(),
                Section         = filterSection,
            };

            //Need to do this to force the model we have changed to refresh
            ModelState.Clear();

            return(thisPageModel);
        }
Exemple #2
0
        private PsfModel GeneratePreSEarchFiltersViewModel(bool singleSelect)
        {
            var filtersModel = new PsfModel()
            {
                OptionsSelected = "TestJSONstring",
                Section         = new PsfSection()
                {
                    Name               = "Multi Select Section One",
                    Description        = "Dummy Title One",
                    SingleSelectOnly   = singleSelect,
                    NextPageUrl        = "NextSectionURL",
                    PreviousPageUrl    = "HomePageURL",
                    PageNumber         = 1,
                    TotalNumberOfPages = 2,
                    SectionDataType    = "Dummy Data Type One"
                },
            };

            filtersModel.Section.Options = new List <PsfOption>();

            for (int ii = 0; ii < 3; ii++)
            {
                var iiString = ii.ToString();
                filtersModel.Section.Options.Add(item: new PsfOption {
                    Id = iiString, IsSelected = false, Name = $"Title-{iiString}", Description = $"Description-{iiString}", OptionKey = $"{iiString}-UrlName", ClearOtherOptionsIfSelected = false
                });
            }

            //Add in a N/A
            filtersModel.Section.Options.Add(item: new PsfOption {
                Id = "3", IsSelected = false, Name = $"Title-3", Description = $"Description-3", OptionKey = $"3-UrlName", ClearOtherOptionsIfSelected = true
            });

            return(filtersModel);
        }
        public ActionResult Index(PsfModel model, PsfSearchResultsViewModel resultsViewModel)
        {
            CheckForBackState(model);

            // If the previous page is search page then, there will not be any sections in the passed PSFModel
            var previousPsfPage = model?.Section == null ? resultsViewModel?.PreSearchFiltersModel : model;

            if (previousPsfPage != null)
            {
                preSearchFilterStateManager.RestoreState(previousPsfPage.OptionsSelected);
                if (preSearchFilterStateManager.ShouldSaveState(ThisPageNumber, previousPsfPage.Section.PageNumber))
                {
                    var previousFilterSection = autoMapper.Map <PreSearchFilterSection>(previousPsfPage.Section);
                    preSearchFilterStateManager.SaveState(previousFilterSection);
                }
            }

            var currentPageFilter = GetCurrentPageFilter();

            if (ThisPageNumber > 1 && UsePageProfileCount)
            {
                var numberOfMatches = asyncHelper.Synchronise(() => GetNumberOfMatches(currentPageFilter));
                currentPageFilter.NumberOfMatchesMessage = string.Format(NumberOfMatchesMessage, numberOfMatches);
                currentPageFilter.UsePageProfileCount    = UsePageProfileCount;
            }

            return(View(currentPageFilter));
        }
Exemple #4
0
        private async Task <ActionResult> DisplaySearchResultsAsync(PsfModel model, int page, bool notPaging = true)
        {
            var resultModel = GetPsfSearchResultsViewModel(model, notPaging);

            var pageNumber       = page > 0 ? page : 1;
            var fieldDefinitions = GetIndexFieldDefinitions();
            var resultsModel     = mapper.Map <PreSearchFiltersResultsModel>(model);
            var properties       = new SearchProperties
            {
                Page     = pageNumber,
                Count    = this.PageSize,
                FilterBy = buildSearchFilterService.BuildPreSearchFilters(resultsModel, fieldDefinitions.ToDictionary(k => k.Key, v => v.Value))
            };
            var results = await searchQueryService.SearchAsync("*", properties);

            resultModel.Count         = results.Count;
            resultModel.PageNumber    = pageNumber;
            resultModel.SearchResults = mapper.Map <IEnumerable <JobProfileSearchResultItemViewModel> >(results.Results);
            foreach (var resultItem in resultModel.SearchResults)
            {
                resultItem.ResultItemUrlName = $"{JobProfileDetailsPage}{resultItem.ResultItemUrlName}";
            }

            SetTotalResultsMessage(resultModel);
            SetupPagination(resultModel);
            return(View("SearchResult", resultModel));
        }
Exemple #5
0
        private PsfModel GeneratePreSearchFiltersViewModel()
        {
            var filtersModel = new PsfModel {
                Sections = new List <PsfSection>()
            };

            var filterSectionOne = new PsfSection
            {
                Name               = "Multi Select Section One",
                Description        = "Dummy Title One",
                SingleSelectOnly   = false,
                NextPageUrl        = "NextSectionURL",
                PreviousPageUrl    = "HomePageURL",
                PageNumber         = 1,
                TotalNumberOfPages = 2,
                SectionDataType    = "Dummy Data Type One",
                Options            = new List <PsfOption>()
            };

            for (int ii = 0; ii < 3; ii++)
            {
                var iiString = ii.ToString();
                filterSectionOne.Options.Add(new PsfOption {
                    Id = iiString, IsSelected = false, Name = $"Title-{iiString}", Description = $"Description-{iiString}", OptionKey = $"{iiString}-UrlName", ClearOtherOptionsIfSelected = false
                });
            }

            //Add one thats Non Applicable
            filterSectionOne.Options.Add(new PsfOption {
                Id = "3", IsSelected = false, Name = "Title-3", Description = "Description-3", OptionKey = "3-UrlName", ClearOtherOptionsIfSelected = true
            });

            filtersModel.Sections.Add(filterSectionOne);

            var filterSectionTwo = new PsfSection
            {
                Name               = "Single Select Section Two",
                Description        = "Dummy Title Two",
                SingleSelectOnly   = true,
                NextPageUrl        = "SearchPageURL",
                PreviousPageUrl    = "PreviousPageURL",
                PageNumber         = 2,
                TotalNumberOfPages = 2,
                SectionDataType    = "Dummy Data Type Two"
            };

            filterSectionTwo.Options = new List <PsfOption>();
            for (int ii = 0; ii < 3; ii++)
            {
                var iiString = ii.ToString();
                filterSectionTwo.Options.Add(new PsfOption {
                    Id = iiString, IsSelected = false, Name = $"Title-{iiString}", Description = $"Description-{iiString}", OptionKey = $"{iiString}-UrlName", ClearOtherOptionsIfSelected = false
                });
            }

            filtersModel.Sections.Add(filterSectionTwo);
            return(filtersModel);
        }
 private void SetDefaultForCovidJobProfiles(PsfModel currentPageFilter, bool doesNotHaveSavedState)
 {
     //Only do this on the Training routes page (Which is been used for Covid affected filter)
     //Only do this the first time the page is loaded
     if (FilterType == PreSearchFilterType.TrainingRoute && doesNotHaveSavedState)
     {
         currentPageFilter.Section.Options.Where(s => s.Name == "No").FirstOrDefault().IsSelected = true;
         currentPageFilter.Section.SingleSelectedValue = "No";
     }
 }
Exemple #7
0
        private PsfSearchResultsViewModel GetPsfSearchResultsViewModel(PsfModel model, bool notPaging)
        {
            preSearchFilterStateManager.RestoreState(model.OptionsSelected);
            if (notPaging)
            {
                if (model.Section.SingleSelectedValue != null)
                {
                    model.Section.SingleSelectOnly = true;
                    var optionSelec =
                        model.Section.Options.FirstOrDefault(o => o.OptionKey == model.Section.SingleSelectedValue);
                    if (optionSelec != null)
                    {
                        optionSelec.IsSelected = true;
                    }
                }
                else
                {
                    model.Section.SingleSelectOnly = false;
                }

                var psfilterSection = mapper.Map <PreSearchFilterSection>(model.Section);

                preSearchFilterStateManager.UpdateSectionState(psfilterSection);
            }

            var filterState = preSearchFilterStateManager.GetPreSearchFilterState();

            model.Sections = mapper.Map <List <PsfSection> >(filterState.Sections);

            var resultModel = new PsfSearchResultsViewModel
            {
                MainPageTitle         = MainPageTitle,
                SecondaryText         = SecondaryText,
                OverviewMessage       = OverviewMessage,
                PreSearchFiltersModel = new PsfModel
                {
                    OptionsSelected = preSearchFilterStateManager.GetStateJson(),
                    Section         = new PsfSection
                    {
                        PageNumber = notPaging ? model.Section.PageNumber++ : model.Section.PageNumber
                    }
                },
                BackPageUrl            = new Uri(BackPageUrl, UriKind.RelativeOrAbsolute),
                BackPageUrlText        = BackPageUrlText,
                JobProfileCategoryPage = JobProfileCategoryPage,
                SalaryBlankText        = SalaryBlankText,
                CaveatTagMarkup        = CaveatTagMarkup,
                CaveatMarkup           = CaveatMarkup
            };

            //Need to do this to force the model we have changed to refresh
            ModelState.Clear();

            return(resultModel);
        }
        public void ShowMatchingProfileCountOnPageTest(int pageNumber, bool showMatchingProfileCount, bool expectingToShowCount)
        {
            //Setup the fakes and dummies for test
            SetUpFakesAndCalls();
            SetUpStateMangerFakesAndCalls(PreSearchFilterType.Interest, true);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <JobProfilesAutoMapperProfile>();
            });
            var mapper = config.CreateMapper();

            var searchResults = new SearchResult <JobProfileIndex>()
            {
                Count = 5
            };

            A.CallTo(() => fakeBuildSearchFilterService.BuildPreSearchFilters(A <PreSearchFiltersResultsModel> ._, A <Dictionary <string, PreSearchFilterLogicalOperator> > ._)).Returns(nameof(SearchProperties.FilterBy));
            A.CallTo(() => fakeBuildSearchFilterService.GetIndexFieldDefinitions(A <string> .Ignored)).Returns(new List <KeyValuePair <string, PreSearchFilterLogicalOperator> >());
            A.CallTo(() => fakeSearchQueryService.SearchAsync(A <string> ._, A <SearchProperties> ._)).Returns(searchResults);

            //Instantiate & Act
            var preSearchFiltersController =
                new PreSearchFiltersController(loggerFake, mapper, psfRepositoryFactoryFake, fakePsfStateManager, fakeSearchQueryService, fakeBuildSearchFilterService, fakeAsyncHelper, fakeTaxonomyRepository)
            {
                FilterType = PreSearchFilterType.Interest
            };

            preSearchFiltersController.ThisPageNumber      = pageNumber;
            preSearchFiltersController.UsePageProfileCount = showMatchingProfileCount;

            //Act on the index
            var firstVm          = new PsfModel();
            var resultsViewModel = new PsfSearchResultsViewModel
            {
                PreSearchFiltersModel = GeneratePreSEarchFiltersViewModel(PreSearchFilterType.Interest)
            };

            var postFromResultsPageCall = preSearchFiltersController.WithCallTo(c => c.Index(firstVm, resultsViewModel));

            postFromResultsPageCall.ShouldRenderDefaultView().WithModel <PsfModel>(vm =>
            {
                vm.UsePageProfileCount.Should().Be(expectingToShowCount);
            }).AndNoModelErrors();

            if (expectingToShowCount)
            {
                A.CallTo(() => fakeSearchQueryService.SearchAsync(A <string> ._, A <SearchProperties> ._)).MustHaveHappened();
            }
            else
            {
                A.CallTo(() => fakeSearchQueryService.SearchAsync(A <string> ._, A <SearchProperties> ._)).MustNotHaveHappened();
            }
        }
Exemple #9
0
 public ActionResult Index(PsfModel model, PsfSearchResultsViewModel resultsViewModel, int page = 1)
 {
     if (model?.Section != null)
     {
         return(Search(model, page));
     }
     else
     {
         return(Search(resultsViewModel?.PreSearchFiltersModel, page, false));
     }
 }
        private void CheckForBackState(PsfModel model)
        {
            //if we have gone backwards, set the model up for the page
            if (model?.Back?.OptionsSelected != null)
            {
                model.Section = new PsfSection()
                {
                    Name             = SectionTitle,
                    SectionDataType  = FilterType.ToString(),
                    PageNumber       = ThisPageNumber,
                    SingleSelectOnly = SingleSelectOnly,
                };

                model.OptionsSelected = model.Back.OptionsSelected;
            }
        }
Exemple #11
0
        private async Task <ActionResult> DisplaySearchResultsAsync(PsfModel model, int page, bool notPaging = true)
        {
            var resultModel = GetPsfSearchResultsViewModel(model, notPaging);

            var pageNumber       = page > 0 ? page : 1;
            var fieldDefinitions = GetIndexFieldDefinitions();
            var resultsModel     = mapper.Map <PreSearchFiltersResultsModel>(model);
            var properties       = new SearchProperties
            {
                Page         = pageNumber,
                SearchFields = new List <string>()
                {
                    IndexSearchField
                },
                Count            = this.PageSize,
                UseRawSearchTerm = true,
                FilterBy         = buildSearchFilterService.BuildPreSearchFilters(resultsModel, fieldDefinitions.ToDictionary(k => k.Key, v => v.Value)),
                OrderByFields    = IndexSortField.TrimEnd(',').Split(',').ToList(),
            };

            var searchTerm = buildSearchFilterService.GetSearchTerm(properties, resultsModel, IndexSearchField.Split(','));
            var results    = await searchQueryService.SearchAsync(searchTerm, properties);

            resultModel.Count         = results.Count;
            resultModel.PageNumber    = pageNumber;
            resultModel.SearchResults = mapper.Map <IEnumerable <JobProfileSearchResultItemViewModel> >(results.Results, opts =>
            {
                opts.Items.Add(nameof(CaveatFinderIndexFieldName), CaveatFinderIndexFieldName);
                opts.Items.Add(nameof(CaveatFinderIndexValue), CaveatFinderIndexValue);
            });

            if (ShowMacthingSkillCount)
            {
                SetMatchingSkillsCount(resultModel, resultsModel, results);
            }

            foreach (var resultItem in resultModel.SearchResults)
            {
                resultItem.ResultItemUrlName = $"{JobProfileDetailsPage}{resultItem.ResultItemUrlName}";
            }

            SetTotalResultsMessage(resultModel);
            SetupPagination(resultModel);
            return(View("SearchResult", resultModel));
        }
        public void IndexWithPsfResultsTest()
        {
            //Setup the fakes and dummies for test
            SetUpFakesAndCalls();
            SetUpStateMangerFakesAndCalls(PreSearchFilterType.Interest, true);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <JobProfilesAutoMapperProfile>();
            });
            var mapper = config.CreateMapper();

            //Instantiate & Act
            var preSearchFiltersController =
                new PreSearchFiltersController(loggerFake, mapper, psfRepositoryFactoryFake, fakePsfStateManager)
            {
                FilterType = PreSearchFilterType.Interest
            };

            //Act on the index
            var firstVm          = new PsfModel();
            var resultsViewModel = new PsfSearchResultsViewModel
            {
                PreSearchFiltersModel = GeneratePreSEarchFiltersViewModel(PreSearchFilterType.Interest)
            };

            var postFromResultsPageCall = preSearchFiltersController.WithCallTo(c => c.Index(firstVm, resultsViewModel));

            postFromResultsPageCall.ShouldRenderDefaultView().WithModel <PsfModel>(vm =>
            {
                vm.Section.Should().NotBeNull();
            })
            .AndNoModelErrors();

            A.CallTo(() => psfFakeIntrestRepository.GetAllFilters()).MustHaveHappened();
            A.CallTo(() => psfFakeIntrestRepository.GetAllFilters()).MustHaveHappened();

            A.CallTo(() => fakePsfStateManager.RestoreState(A <string> ._)).MustHaveHappened();
            A.CallTo(() => fakePsfStateManager.ShouldSaveState(A <int> ._, A <int> ._)).MustHaveHappened();
            A.CallTo(() => fakePsfStateManager.SaveState(A <PreSearchFilterSection> ._)).MustHaveHappened();
            A.CallTo(() => fakePsfStateManager.GetSavedSection(A <string> ._, A <PreSearchFilterType> ._)).MustHaveHappened();
            A.CallTo(() => fakePsfStateManager.RestoreOptions(A <PreSearchFilterSection> ._, A <IEnumerable <PreSearchFilter> > ._)).MustHaveHappened();
            A.CallTo(() => fakePsfStateManager.GetStateJson()).MustHaveHappened();
        }
        public ActionResult Index(PsfModel model, PsfSearchResultsViewModel resultsViewModel)
        {
            // If the previous page is search page then, there will not be any sections in the passed PSFModel
            var previousPsfPage = model?.Section == null ? resultsViewModel?.PreSearchFiltersModel : model;

            if (previousPsfPage != null)
            {
                preSearchFilterStateManager.RestoreState(previousPsfPage.OptionsSelected);
                if (preSearchFilterStateManager.ShouldSaveState(ThisPageNumber, previousPsfPage.Section.PageNumber))
                {
                    var previousFilterSection = autoMapper.Map <PreSearchFilterSection>(previousPsfPage.Section);
                    preSearchFilterStateManager.SaveState(previousFilterSection);
                }
            }

            var currentPageFilter = GetCurrentPageFilter();

            return(View(currentPageFilter));
        }
        private async Task <int> GetNumberOfMatches(PsfModel model)
        {
            var fieldDefinitions = buildSearchFilterService.GetIndexFieldDefinitions(IndexFieldOperators);

            preSearchFilterStateManager.RestoreState(model.OptionsSelected);
            var filterState = preSearchFilterStateManager.GetPreSearchFilterState();

            model.Sections = autoMapper.Map <List <PsfSection> >(filterState.Sections);

            var resultsModel = autoMapper.Map <PreSearchFiltersResultsModel>(model);
            var properties   = new SearchProperties
            {
                Page     = 0,
                Count    = 0,
                FilterBy = buildSearchFilterService.BuildPreSearchFilters(resultsModel, fieldDefinitions.ToDictionary(k => k.Key, v => v.Value))
            };
            var results = await searchQueryService.SearchAsync("*", properties);

            return((int)results.Count);
        }
        public void IndexNoModelTest()
        {
            //Setup the fakes and dummies for test
            SetUpFakesAndCalls();
            SetUpStateMangerFakesAndCalls(PreSearchFilterType.Interest, false);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <JobProfilesAutoMapperProfile>();
            });
            var mapper = config.CreateMapper();

            //Instantiate & Act
            var preSearchFiltersController =
                new PreSearchFiltersController(loggerFake, mapper, psfRepositoryFactoryFake, fakePsfStateManager)
            {
                FilterType = PreSearchFilterType.Interest
            };

            //Act on the index
            var indexResult = preSearchFiltersController.WithCallTo(c => c.Index());

            PsfModel firstVm = null;

            //Assert
            indexResult.ShouldRenderDefaultView().WithModel <PsfModel>(vm =>
            {
                CheckFilterSecton(preSearchFiltersController, vm.Section, PreSearchFilterType.Interest);
                firstVm = vm;
            }).AndNoModelErrors();

            A.CallTo(() => psfFakeIntrestRepository.GetAllFilters()).MustHaveHappened();

            A.CallTo(() => fakePsfStateManager.RestoreState(A <string> ._)).MustNotHaveHappened();
            A.CallTo(() => fakePsfStateManager.ShouldSaveState(A <int> ._, A <int> ._)).MustNotHaveHappened();
            A.CallTo(() => fakePsfStateManager.SaveState(A <PreSearchFilterSection> ._)).MustNotHaveHappened();

            A.CallTo(() => fakePsfStateManager.GetSavedSection(A <string> ._, A <PreSearchFilterType> ._)).MustHaveHappened();
            A.CallTo(() => fakePsfStateManager.RestoreOptions(A <PreSearchFilterSection> ._, A <IEnumerable <PreSearchFilter> > ._)).MustHaveHappened();
            A.CallTo(() => fakePsfStateManager.GetStateJson()).MustHaveHappened();
        }
Exemple #16
0
        private static void AddFilterSection(PsfSection currentSection, PsfModel model, string demovalues)
        {
            var values = demovalues.Split('~');

            foreach (var value in values)
            {
                var data = value.Split(',');
                if (data.Length == 2)
                {
                    currentSection.Options.Add(new PsfOption
                    {
                        IsSelected = Convert.ToBoolean(data[0]),
                        OptionKey  = Convert.ToString(data[1])
                    });
                }
            }

            if (currentSection.Options.Any())
            {
                model.Sections.Add(currentSection);
            }
        }
        public void BackOptionSelectedStateIsUsedIfSet()
        {
            //Setup the fakes and dummies for test
            SetUpFakesAndCalls();
            SetUpStateMangerFakesAndCalls(PreSearchFilterType.JobArea, false);

            var config = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <JobProfilesAutoMapperProfile>();
            });
            var mapper = config.CreateMapper();

            var firstVm = new PsfModel()
            {
                Back = new PsfBack()
                {
                    OptionsSelected = "DummyOptionsSelectd"
                }
            };

            A.CallTo(() => fakePsfStateManager.GetStateJson()).Returns(firstVm.OptionsSelected);

            //Instantiate & Act
            var preSearchFiltersController = new PreSearchFiltersController(loggerFake, mapper, psfRepositoryFactoryFake, fakePsfStateManager, fakeSearchQueryService, fakeBuildSearchFilterService, fakeAsyncHelper, fakeTaxonomyRepository)
            {
                FilterType = PreSearchFilterType.Interest
            };

            //Act on the index
            var postFromResultsPageCall = preSearchFiltersController.WithCallTo(c => c.Index(firstVm, null));

            postFromResultsPageCall.ShouldRenderDefaultView().WithModel <PsfModel>(vm =>
            {
                vm.Section.Should().NotBeNull();
                vm.Section.SectionDataType.Should().Be(PreSearchFilterType.Interest.ToString());
            })
            .AndNoModelErrors();
        }
        private PsfModel GeneratePreSEarchFiltersViewModel(PreSearchFilterType filterType)
        {
            var filtersModel = new PsfModel {
                OptionsSelected = "DummyJsonState"
            };

            var filterSectionOne = new PsfSection
            {
                Name               = "Multi Select Section One",
                Description        = "Dummy Title One",
                SingleSelectOnly   = false,
                NextPageUrl        = "NextSectionURL",
                PreviousPageUrl    = "HomePageURL",
                PageNumber         = 1,
                TotalNumberOfPages = 2,
                SectionDataType    = filterType.ToString()
            };

            filterSectionOne.Options = new List <PsfOption>();

            for (int ii = 0; ii < 3; ii++)
            {
                var iiString = ii.ToString();
                filterSectionOne.Options.Add(item: new PsfOption
                {
                    Id          = iiString,
                    IsSelected  = false,
                    Name        = $"Title-{iiString}",
                    Description = $"Description-{iiString}",
                    OptionKey   = $"{iiString}-UrlName",
                    ClearOtherOptionsIfSelected = false
                });
            }

            filtersModel.Section = filterSectionOne;

            return(filtersModel);
        }
        private PsfModel GetCurrentPageFilter()
        {
            var savedSection    = preSearchFilterStateManager.GetSavedSection(SectionTitle, FilterType);
            var restoredSection = preSearchFilterStateManager.RestoreOptions(savedSection, GetFilterOptions());
            var groupedSections = restoredSection.Options.GroupBy(o => o.PSFCategory).OrderBy(g => g.Key);

            //create the section for this page
            var currentSection = autoMapper.Map <PsfSection>(restoredSection);

            var filterSection = currentSection ?? new PsfSection();

            filterSection.Name               = SectionTitle;
            filterSection.Description        = SectionDescription;
            filterSection.SingleSelectOnly   = SingleSelectOnly;
            filterSection.NextPageUrl        = NextPageUrl;
            filterSection.PreviousPageUrl    = PreviousPageUrl;
            filterSection.PageNumber         = ThisPageNumber;
            filterSection.EnableAccordion    = EnableAccordion;
            filterSection.GroupFieldsBy      = GroupFieldsBy;
            filterSection.TotalNumberOfPages = TotalNumberOfPages;
            filterSection.SectionDataType    = FilterType.ToString();
            filterSection.SelectMessage      = SelectMessage;
            var thisPageModel = new PsfModel
            {
                //Throw the state out again
                OptionsSelected        = preSearchFilterStateManager.GetStateJson(),
                Section                = filterSection,
                GroupedOptions         = groupedSections,
                NumberOfMatchesMessage = NumberOfMatchesMessage,
            };

            //Need to do this to force the model we have changed to refresh
            ModelState.Clear();

            SetDefaultForCovidJobProfiles(thisPageModel, savedSection == null);

            return(thisPageModel);
        }
Exemple #20
0
        private PsfModel GetDummyPreSearchFiltersModel()
        {
            var model = new PsfModel
            {
                Sections = new List <PsfSection>(),
                Section  = new PsfSection {
                    Options = new List <PsfOption>()
                }
            };

            // interests
            var interestSection = new PsfSection
            {
                Name            = nameof(JobProfileIndex.Interests),
                Options         = new List <PsfOption>(),
                SectionDataType = "Interest",
            };

            if (!string.IsNullOrWhiteSpace(DemoInterestsValues))
            {
                AddFilterSection(interestSection, model, DemoInterestsValues);
            }

            // enablers
            var enablersSection = new PsfSection
            {
                Name            = nameof(JobProfileIndex.Enablers),
                SectionDataType = nameof(PreSearchFilterType.Enabler),
                Options         = new List <PsfOption>(),
            };

            if (!string.IsNullOrWhiteSpace(DemoEnablersValues))
            {
                AddFilterSection(enablersSection, model, DemoEnablersValues);
            }

            // training routes
            var trainingRouteSection = new PsfSection
            {
                Name            = nameof(JobProfileIndex.TrainingRoutes),
                SectionDataType = nameof(PreSearchFilterType.TrainingRoute),
                Options         = new List <PsfOption>(),
            };

            if (!string.IsNullOrWhiteSpace(DemoTrainingRoutesValues))
            {
                AddFilterSection(trainingRouteSection, model, DemoTrainingRoutesValues);
            }

            // entry qualifics
            var entrySection = new PsfSection
            {
                Name            = nameof(JobProfileIndex.EntryQualifications),
                Options         = new List <PsfOption>(),
                SectionDataType = nameof(PreSearchFilterType.EntryQualification),
            };

            if (!string.IsNullOrWhiteSpace(DemoEntryQualificationsValues))
            {
                AddFilterSection(entrySection, model, DemoEntryQualificationsValues);
            }

            //job areas
            var jobAreas = new PsfSection
            {
                Name            = nameof(JobProfileIndex.EntryQualifications),
                Options         = new List <PsfOption>(),
                SectionDataType = nameof(PreSearchFilterType.JobArea),
            };

            if (!string.IsNullOrWhiteSpace(DemoJobAreasValues))
            {
                AddFilterSection(jobAreas, model, DemoJobAreasValues);
            }

            // preferred tasks
            var preferredTasks = new PsfSection
            {
                Name            = nameof(JobProfileIndex.EntryQualifications),
                Options         = new List <PsfOption>(),
                SectionDataType = nameof(PreSearchFilterType.PreferredTaskType),
            };

            if (!string.IsNullOrWhiteSpace(DemoPreferredTaskTypesValues))
            {
                AddFilterSection(preferredTasks, model, DemoPreferredTaskTypesValues);
            }

            return(model);
        }
Exemple #21
0
 public ActionResult Search(PsfModel model, int page = 1, bool notPaging = true)
 {
     return(asyncHelper.Synchronise(() => DisplaySearchResultsAsync(model, page, notPaging)));
 }