Exemple #1
0
        public IActionResult Index(
            string?searchString         = null,
            string?sortBy               = null,
            string sortDirection        = GenericSortingHelper.Ascending,
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false,
            int page         = 1,
            int?itemsPerPage = null
            )
        {
            sortBy ??= DefaultSortByOptions.Name.PropertyName;
            existingFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                CourseFilterCookieName,
                CourseStatusFilterOptions.IsActive.FilterValue
                );

            var centreId   = User.GetCentreId();
            var categoryId = User.GetAdminCourseCategoryFilter();

            var details = courseService.GetCentreCourseDetails(centreId, categoryId);

            var availableFilters = CourseStatisticsViewModelFilterOptions
                                   .GetFilterOptions(categoryId.HasValue ? new string[] { } : details.Categories, details.Topics).ToList();

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString),
                new SortOptions(sortBy, sortDirection),
                new FilterOptions(
                    existingFilterString,
                    availableFilters,
                    CourseStatusFilterOptions.IsActive.FilterValue
                    ),
                new PaginationOptions(page, itemsPerPage)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                details.Courses,
                searchSortPaginationOptions
                );

            var model = new CourseSetupViewModel(
                result,
                availableFilters,
                config
                );

            Response.UpdateFilterCookie(CourseFilterCookieName, result.FilterString);

            return(View(model));
        }
Exemple #2
0
        public IActionResult Index(int page = 1)
        {
            var adminId = User.GetAdminId() !.Value;
            var unacknowledgedNotifications =
                systemNotificationsDataService.GetUnacknowledgedSystemNotifications(adminId).ToList();

            if (unacknowledgedNotifications.Count > 0)
            {
                Response.Cookies.SetSkipSystemNotificationCookie(adminId, clockService.UtcNow);
            }
            else if (Request.Cookies.HasSkippedNotificationsCookie(adminId))
            {
                Response.Cookies.DeleteSkipSystemNotificationCookie();
            }

            const int numberOfNotificationsPerPage = 1;
            var       searchSortPaginationOptions  = new SearchSortFilterAndPaginateOptions(
                null,
                null,
                null,
                new PaginationOptions(page, numberOfNotificationsPerPage)
                );
            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                unacknowledgedNotifications,
                searchSortPaginationOptions
                );

            var model = new SystemNotificationsViewModel(result);

            return(View(model));
        }
Exemple #3
0
        public void AddCourseToGroupSelectCourse_calls_expected_methods_and_returns_view()
        {
            // When
            var result = groupCoursesController.AddCourseToGroupSelectCourse(1);

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => courseService.GetEligibleCoursesToAddToGroup(A <int> ._, A <int?> ._, A <int> ._))
                .MustHaveHappened();
                A.CallTo(() => courseService.GetCategoriesForCentreAndCentrallyManagedCourses(A <int> ._))
                .MustHaveHappened();
                A.CallTo(() => courseService.GetTopicsForCentreAndCentrallyManagedCourses(A <int> ._)).MustHaveHappened();
                A.CallTo(() => groupsService.GetGroupName(A <int> ._, A <int> ._)).MustHaveHappened();
                A.CallTo(
                    () => searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                        A <IEnumerable <CourseAssessmentDetails> > ._,
                        A <SearchSortFilterAndPaginateOptions> ._
                        )
                    ).MustHaveHappened();
                A.CallTo(
                    () => httpResponse.Cookies.Append(
                        CookieName,
                        A <string> ._,
                        A <CookieOptions> ._
                        )
                    )
                .MustHaveHappened();
                result.Should().BeViewResult().WithDefaultViewName();
            }
        }
Exemple #4
0
        public void Index_calls_expected_methods_and_returns_view()
        {
            // When
            var result = emailDelegatesController.Index();

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => userService.GetDelegateUserCardsForWelcomeEmail(A <int> ._)).MustHaveHappened();
                A.CallTo(() => centreRegistrationPromptsService.GetCentreRegistrationPromptsByCentreId(A <int> ._))
                .MustHaveHappened();
                A.CallTo(
                    () => searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                        A <IEnumerable <DelegateUserCard> > ._,
                        A <SearchSortFilterAndPaginateOptions> ._
                        )
                    ).MustHaveHappened();
                A.CallTo(
                    () => httpResponse.Cookies.Append(
                        CookieName,
                        A <string> ._,
                        A <CookieOptions> ._
                        )
                    )
                .MustHaveHappened();
                result.Should().BeViewResult().WithDefaultViewName();
            }
        }
        public void SelectDelegate_calls_expected_methods_and_returns_view()
        {
            // When
            var result = groupDelegatesController.SelectDelegate(1);

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => userService.GetDelegatesNotRegisteredForGroupByGroupId(A <int> ._, A <int> ._))
                .MustHaveHappened();
                A.CallTo(() => jobGroupsService.GetJobGroupsAlphabetical())
                .MustHaveHappened();
                A.CallTo(() => groupsService.GetGroupName(A <int> ._, A <int> ._)).MustHaveHappened();
                A.CallTo(
                    () => searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                        A <IEnumerable <DelegateUserCard> > ._,
                        A <SearchSortFilterAndPaginateOptions> ._
                        )
                    ).MustHaveHappened();
                A.CallTo(
                    () => httpResponse.Cookies.Append(
                        AddGroupDelegateFilterCookieName,
                        A <string> ._,
                        A <CookieOptions> ._
                        )
                    )
                .MustHaveHappened();
                result.Should().BeViewResult().WithDefaultViewName();
            }
        }
Exemple #6
0
        private async Task <IActionResult> ReturnSignpostingRecommendedLearningView(
            int selfAssessmentId,
            int candidateId,
            int page,
            string?searchString
            )
        {
            var assessment = selfAssessmentService.GetSelfAssessmentForCandidateById(candidateId, selfAssessmentId) !;

            var(recommendedResources, apiIsAccessible) =
                await recommendedLearningService.GetRecommendedLearningForSelfAssessment(selfAssessmentId, candidateId);

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString),
                new SortOptions(nameof(RecommendedResource.RecommendationScore), GenericSortingHelper.Descending),
                null,
                new PaginationOptions(page)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                recommendedResources,
                searchSortPaginationOptions
                );

            var model = new RecommendedLearningViewModel(
                assessment,
                result,
                apiIsAccessible
                );

            return(View("RecommendedLearning", model));
        }
        public IActionResult LearningLog(
            int progressId,
            DelegateAccessRoute accessedVia,
            string?sortBy        = null,
            string sortDirection = GenericSortingHelper.Descending
            )
        {
            sortBy ??= LearningLogSortByOptions.When.PropertyName;
            var learningLog = courseService.GetLearningLogDetails(progressId);

            if (learningLog == null)
            {
                return(NotFound());
            }

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                null,
                new SortOptions(sortBy, sortDirection),
                null,
                null
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                learningLog.Entries,
                searchSortPaginationOptions
                );

            var model = new LearningLogViewModel(accessedVia, learningLog, result);

            return(View(model));
        }
 public static void GivenACallToSearchSortFilterPaginateServiceReturnsResult <T>(
     ISearchSortFilterPaginateService searchSortFilterPaginateService,
     int maxItemsBeforeJavascriptSearchDisabled = 250
     ) where T : BaseSearchableItem
 {
     A.CallTo(
         () => searchSortFilterPaginateService.SearchFilterSortAndPaginate(
             A <IEnumerable <T> > ._,
             A <SearchSortFilterAndPaginateOptions> ._
             )
         ).ReturnsLazily(
         x =>
     {
         var items = x.Arguments.Get <IEnumerable <T> >("items")?.ToList() ??
                     new List <T>();
         var options =
             x.Arguments.Get <SearchSortFilterAndPaginateOptions>("searchSortFilterAndPaginateOptions");
         return(new SearchSortFilterPaginationResult <T>(
                    new PaginationResult <T>(
                        items,
                        options !.PaginationOptions?.PageNumber ?? 1,
                        1,
                        options.PaginationOptions?.ItemsPerPage ?? int.MaxValue,
                        items.Count,
                        items.Count <= maxItemsBeforeJavascriptSearchDisabled
                        ),
                    options.SearchOptions?.SearchString,
                    options.SortOptions?.SortBy,
                    options.SortOptions?.SortDirection,
                    options.FilterOptions?.FilterString
                    ));
     }
         );
 }
Exemple #9
0
        public void Index_calls_expected_methods_and_returns_view()
        {
            // When
            var result = delegateGroupsController.Index();

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => groupsService.GetGroupsForCentre(A <int> ._)).MustHaveHappened();
                A.CallTo(
                    () => searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                        A <IEnumerable <Group> > ._,
                        A <SearchSortFilterAndPaginateOptions> ._
                        )
                    ).MustHaveHappened();
                A.CallTo(
                    () => httpResponse.Cookies.Append(
                        CookieName,
                        A <string> ._,
                        A <CookieOptions> ._
                        )
                    )
                .MustHaveHappened();
                result.Should().BeViewResult().WithDefaultViewName();
            }
        }
        public void Index_calls_expected_methods_and_returns_view()
        {
            // When
            var result = controllerWithCookies.Index();

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => courseService.GetCentreCourseDetails(A <int> ._, A <int?> ._)).MustHaveHappened();
                A.CallTo(
                    () => searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                        A <IEnumerable <CourseStatisticsWithAdminFieldResponseCounts> > ._,
                        A <SearchSortFilterAndPaginateOptions> ._
                        )
                    ).MustHaveHappened();
                A.CallTo(
                    () => httpResponse.Cookies.Append(
                        CookieName,
                        A <string> ._,
                        A <CookieOptions> ._
                        )
                    )
                .MustHaveHappened();
                result.Should().BeViewResult().WithDefaultViewName();
            }
        }
Exemple #11
0
        public void Index_calls_expected_methods_and_returns_view()
        {
            // When
            var result = administratorController.Index();

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => userDataService.GetAdminUsersByCentreId(A <int> ._)).MustHaveHappened();
                A.CallTo(() => courseCategoriesDataService.GetCategoriesForCentreAndCentrallyManagedCourses(A <int> ._))
                .MustHaveHappened();
                A.CallTo(() => userDataService.GetAdminUserById(A <int> ._)).MustHaveHappened();
                A.CallTo(
                    () => searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                        A <IEnumerable <AdminUser> > ._,
                        A <SearchSortFilterAndPaginateOptions> ._
                        )
                    ).MustHaveHappened();
                A.CallTo(
                    () => httpResponse.Cookies.Append(
                        CookieName,
                        A <string> ._,
                        A <CookieOptions> ._
                        )
                    )
                .MustHaveHappened();
                result.Should().BeViewResult().WithDefaultViewName();
            }
        }
        public IActionResult Index(
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false,
            bool selectAll = false
            )
        {
            var newFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                EmailDelegateFilterCookieName
                );
            var jobGroups     = jobGroupsDataService.GetJobGroupsAlphabetical();
            var customPrompts = promptsService.GetCentreRegistrationPrompts(User.GetCentreId());
            var delegateUsers = GetDelegateUserCards();

            var promptsWithOptions = customPrompts.Where(customPrompt => customPrompt.Options.Count > 0);
            var availableFilters   = EmailDelegatesViewModelFilterOptions.GetEmailDelegatesFilterModels(
                jobGroups,
                promptsWithOptions
                );

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                null,
                null,
                new FilterOptions(newFilterString, availableFilters),
                null
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                delegateUsers,
                searchSortPaginationOptions
                );

            var model = new EmailDelegatesViewModel(
                result,
                availableFilters,
                selectAll
                );

            Response.UpdateFilterCookie(EmailDelegateFilterCookieName, result.FilterString);

            return(View(model));
        }
        public IActionResult Index(
            int page                    = 1,
            string?searchString         = null,
            string?sortBy               = null,
            string sortDirection        = GenericSortingHelper.Ascending,
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false,
            int?itemsPerPage            = null
            )
        {
            sortBy ??= DefaultSortByOptions.Name.PropertyName;
            existingFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                DelegateFilterCookieName,
                DelegateActiveStatusFilterOptions.IsActive.FilterValue
                );

            var centreId      = User.GetCentreId();
            var jobGroups     = jobGroupsDataService.GetJobGroupsAlphabetical();
            var customPrompts = promptsService.GetCentreRegistrationPrompts(centreId).ToList();
            var delegateUsers = userDataService.GetDelegateUserCardsByCentreId(centreId);

            var promptsWithOptions = customPrompts.Where(customPrompt => customPrompt.Options.Count > 0);
            var availableFilters   = AllDelegatesViewModelFilterOptions.GetAllDelegatesFilterViewModels(
                jobGroups,
                promptsWithOptions
                );

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString),
                new SortOptions(sortBy, sortDirection),
                new FilterOptions(
                    existingFilterString,
                    availableFilters,
                    DelegateActiveStatusFilterOptions.IsActive.FilterValue
                    ),
                new PaginationOptions(page, itemsPerPage)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                delegateUsers,
                searchSortPaginationOptions
                );

            var model = new AllDelegatesViewModel(
                result,
                customPrompts,
                availableFilters
                );

            Response.UpdateFilterCookie(DelegateFilterCookieName, result.FilterString);

            return(View(model));
        }
        public IActionResult Index(
            int brandId,
            int page                    = 1,
            string?sortBy               = null,
            string sortDirection        = GenericSortingHelper.Ascending,
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false
            )
        {
            var brand = brandsService.GetPublicBrandById(brandId);

            if (brand == null)
            {
                return(NotFound());
            }

            sortBy ??= DefaultSortByOptions.Name.PropertyName;
            existingFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                BrandCoursesFilterCookieName
                );

            var tutorials    = tutorialService.GetPublicTutorialSummariesForBrand(brandId);
            var applications = courseService.GetApplicationsThatHaveSectionsByBrandId(brandId).ToList();

            var categories       = applications.Select(x => x.CategoryName).Distinct().OrderBy(x => x).ToList();
            var topics           = applications.Select(x => x.CourseTopic).Distinct().OrderBy(x => x).ToList();
            var availableFilters = LearningContentViewModelFilterOptions
                                   .GetFilterOptions(categories, topics).ToList();

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                null,
                new SortOptions(sortBy, sortDirection),
                new FilterOptions(
                    existingFilterString,
                    availableFilters
                    ),
                new PaginationOptions(page)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                applications,
                searchSortPaginationOptions
                );

            var model = new LearningContentViewModel(result, availableFilters, brand, tutorials);

            Response.UpdateFilterCookie(BrandCoursesFilterCookieName, result.FilterString);

            return(View(model));
        }
Exemple #15
0
        public async Task <IActionResult> Index(
            int page                    = 1,
            string?searchString         = null,
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false,
            int?itemsPerPage            = null
            )
        {
            if (!await featureManager.IsEnabledAsync(FeatureFlags.RefactoredFindYourCentrePage))
            {
                var model = new FindYourCentreViewModel(configuration);

                return(View("Index", model));
            }

            existingFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                FindCentreFilterCookieName
                );

            var centreSummaries = centresService.GetAllCentreSummariesForFindCentre();
            var regions         = regionDataService.GetRegionsAlphabetical();

            var availableFilters = FindYourCentreViewModelFilterOptions
                                   .GetFindCentreFilterModels(regions).ToList();

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString, searchMatchCutoff: 90),
                null,
                new FilterOptions(
                    existingFilterString,
                    availableFilters
                    ),
                new PaginationOptions(page, itemsPerPage)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                centreSummaries,
                searchSortPaginationOptions
                );

            var refactoredModel = new RefactoredFindYourCentreViewModel(
                result,
                availableFilters
                );

            Response.UpdateFilterCookie(FindCentreFilterCookieName, result.FilterString);

            return(View("RefactoredFindYourCentre", refactoredModel));
        }
Exemple #16
0
        public IActionResult Index(int groupId, int page = 1)
        {
            var centreId  = User.GetCentreId();
            var groupName = groupsService.GetGroupName(groupId, centreId);

            var groupDelegates = groupsService.GetGroupDelegates(groupId);

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                null,
                null,
                null,
                new PaginationOptions(page)
                );
            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                groupDelegates,
                searchSortPaginationOptions
                );

            var model = new GroupDelegatesViewModel(groupId, groupName !, result);

            return(View(model));
        }
        public void SearchFilterSortAndPaginate_with_search_only_returns_expected_result()
        {
            // Given
            var options = new SearchSortFilterAndPaginateOptions(new SearchOptions("A"), null, null, null);

            // When
            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(allItems, options);

            // Then
            var expectedResult = new SearchSortFilterPaginationResult <SortableItem>(
                new PaginationResult <SortableItem>(new[] { new SortableItem("A", 10) }, 1, 1, int.MaxValue, 1, true),
                "A",
                null,
                null,
                null
                );

            result.Should().BeEquivalentTo(expectedResult);
        }
        public IActionResult Index(
            string?searchString         = null,
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false,
            int page         = 1,
            int?itemsPerPage = null
            )
        {
            existingFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                AdminFilterCookieName
                );

            var centreId           = User.GetCentreId();
            var adminUsersAtCentre = userDataService.GetAdminUsersByCentreId(centreId);
            var categories         = courseCategoriesDataService.GetCategoriesForCentreAndCentrallyManagedCourses(centreId);
            var loggedInUserId     = User.GetAdminId();
            var loggedInAdminUser  = userDataService.GetAdminUserById(loggedInUserId !.GetValueOrDefault());

            var availableFilters =
                AdministratorsViewModelFilterOptions.GetAllAdministratorsFilterModels(categories);

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString),
                new SortOptions(GenericSortingHelper.DefaultSortOption, GenericSortingHelper.Ascending),
                new FilterOptions(existingFilterString, availableFilters),
                new PaginationOptions(page, itemsPerPage)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                adminUsersAtCentre,
                searchSortPaginationOptions
                );

            var model = new CentreAdministratorsViewModel(
                centreId,
                result,
                availableFilters,
                loggedInAdminUser !
                );

            Response.UpdateFilterCookie(AdminFilterCookieName, result.FilterString);

            return(View(model));
        }
Exemple #19
0
        public IActionResult Index(
            string?searchString         = null,
            string?sortBy               = null,
            string sortDirection        = GenericSortingHelper.Ascending,
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false,
            int page = 1
            )
        {
            sortBy ??= DefaultSortByOptions.Name.PropertyName;
            existingFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                DelegateGroupsFilterCookieName
                );

            var centreId            = User.GetCentreId();
            var groups              = groupsService.GetGroupsForCentre(centreId).ToList();
            var registrationPrompts = GetRegistrationPromptsWithSetOptions(centreId);
            var availableFilters    = DelegateGroupsViewModelFilterOptions
                                      .GetDelegateGroupFilterModels(groups, registrationPrompts).ToList();

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString),
                new SortOptions(sortBy, sortDirection),
                new FilterOptions(existingFilterString, availableFilters),
                new PaginationOptions(page)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                groups,
                searchSortPaginationOptions
                );

            var model = new DelegateGroupsViewModel(
                result,
                availableFilters
                );

            Response.UpdateFilterCookie(DelegateGroupsFilterCookieName, result.FilterString);

            return(View(model));
        }
Exemple #20
0
        public void Index_returns_not_found_with_null_brand()
        {
            // Given
            A.CallTo(() => brandsService.GetPublicBrandById(A <int> ._)).Returns(null);

            // When
            var result = controller.Index(1);

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => tutorialService.GetPublicTutorialSummariesForBrand(A <int> ._)).MustNotHaveHappened();
                A.CallTo(() => courseService.GetApplicationsThatHaveSectionsByBrandId(A <int> ._)).MustNotHaveHappened();
                A.CallTo(
                    () => searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                        A <IEnumerable <ApplicationWithSections> > ._,
                        A <SearchSortFilterAndPaginateOptions> ._
                        )
                    ).MustNotHaveHappened();
                result.Should().BeNotFoundResult();
            }
        }
Exemple #21
0
        public IActionResult Index(
            DlsSubApplication dlsSubApplication,
            int page            = 1,
            string?searchString = null
            )
        {
            // A MatchCutOffScore of 65 is being used here rather than the default 80.
            // The default Fuzzy Search configuration does not reliably bring back expected FAQs.
            // Through trial and error a combination of the PartialTokenSetScorer ratio scorer
            // and this cut off score bring back reliable results comparable to the JS search.
            const int    matchCutOffScore = 65;
            const string faqSortBy        = "Weighting,FaqId";

            var faqs = faqsService.GetPublishedFaqsForTargetGroup(dlsSubApplication.FaqTargetGroupId !.Value)
                       .Select(f => new SearchableFaq(f));

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                new SearchOptions(searchString, matchCutOffScore, true),
                new SortOptions(faqSortBy, GenericSortingHelper.Descending),
                null,
                new PaginationOptions(page)
                );

            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                faqs,
                searchSortPaginationOptions
                );

            var model = new FaqsPageViewModel(
                dlsSubApplication,
                SupportPage.Faqs,
                configuration.GetCurrentSystemBaseUrl(),
                result
                );

            return(View("Faqs", model));
        }
        public IActionResult Index(
            int?customisationId         = null,
            string?searchString         = null,
            string?sortBy               = null,
            string sortDirection        = GenericSortingHelper.Ascending,
            string?existingFilterString = null,
            string?newFilterToAdd       = null,
            bool clearFilters           = false,
            int page = 1
            )
        {
            sortBy ??= DefaultSortByOptions.Name.PropertyName;
            var newFilterString = FilteringHelper.GetFilterString(
                existingFilterString,
                newFilterToAdd,
                clearFilters,
                Request,
                CourseDelegatesFilterCookieName,
                CourseDelegateAccountStatusFilterOptions.Active.FilterValue
                );

            var centreId        = User.GetCentreId();
            var adminCategoryId = User.GetAdminCourseCategoryFilter();

            try
            {
                var courseDelegatesData = courseDelegatesService.GetCoursesAndCourseDelegatesForCentre(
                    centreId,
                    adminCategoryId,
                    customisationId
                    );

                var availableFilters = CourseDelegateViewModelFilterOptions.GetAllCourseDelegatesFilterViewModels(
                    courseDelegatesData.CourseAdminFields
                    );

                var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                    new SearchOptions(searchString),
                    new SortOptions(sortBy, sortDirection),
                    new FilterOptions(
                        newFilterString,
                        availableFilters,
                        CourseDelegateAccountStatusFilterOptions.Active.FilterValue
                        ),
                    new PaginationOptions(page)
                    );

                var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                    courseDelegatesData.Delegates,
                    searchSortPaginationOptions
                    );

                var model = new CourseDelegatesViewModel(
                    courseDelegatesData,
                    result,
                    availableFilters,
                    "customisationId"
                    );

                Response.UpdateFilterCookie(CourseDelegatesFilterCookieName, result.FilterString);
                return(View(model));
            }
            catch (CourseAccessDeniedException)
            {
                return(NotFound());
            }
        }