private SelectCourseViewModel GetSelectCourseViewModel( string?categoryFilterString, string?topicFilterString, int?selectedApplicationId = null ) { var centreId = User.GetCentreId(); var categoryIdFilter = User.GetAdminCourseCategoryFilter() !; var applications = courseService .GetApplicationOptionsAlphabeticalListForCentre(centreId, categoryIdFilter).ToList(); var categories = courseService.GetCategoriesForCentreAndCentrallyManagedCourses(centreId); var topics = courseService.GetTopicsForCentreAndCentrallyManagedCourses(centreId); var availableFilters = (categoryIdFilter == null ? SelectCourseViewModelFilterOptions.GetAllCategoriesFilters( categories, topics, categoryFilterString, topicFilterString ) : SelectCourseViewModelFilterOptions.GetSingleCategoryFilters( applications, categoryFilterString, topicFilterString )).ToList(); var currentFilterString = FilteringHelper.GetCategoryAndTopicFilterString(categoryFilterString, topicFilterString); var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions( null, new SortOptions(nameof(ApplicationDetails.ApplicationName), GenericSortingHelper.Ascending), new FilterOptions(currentFilterString, availableFilters), null ); var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate( applications, searchSortPaginationOptions ); return(new SelectCourseViewModel( result, availableFilters, categoryFilterString, topicFilterString, selectedApplicationId )); }