public AllCourseStatisticsViewModel(CentreCourseDetails details, IConfiguration config)
        {
            Courses = details.Courses.Select(c => new SearchableCourseStatisticsViewModel(c, config));

            Filters = CourseStatisticsViewModelFilterOptions.GetFilterOptions(details.Categories, details.Topics)
                      .SelectAppliedFilterViewModels();
        }
Exemple #2
0
        public CourseSetupViewModel(
            IEnumerable <CourseStatistics> courses,
            IEnumerable <string> categories,
            IEnumerable <string> topics,
            string?searchString,
            string sortBy,
            string sortDirection,
            string?filterBy,
            int page
            ) : base(searchString, page, true, sortBy, sortDirection, filterBy, searchLabel: "Search courses")
        {
            var sortedItems = GenericSortingHelper.SortAllItems(
                courses.AsQueryable(),
                sortBy,
                sortDirection
                );

            var filteredItems = FilteringHelper.FilterItems(sortedItems.AsQueryable(), filterBy).ToList();
            var searchedItems = GenericSearchHelper.SearchItems(filteredItems, SearchString).ToList();

            MatchingSearchResults = searchedItems.Count;
            SetTotalPages();
            var paginatedItems = GetItemsOnCurrentPage(searchedItems);

            Courses = paginatedItems.Select(c => new SearchableCourseStatisticsViewModel(c));

            Filters = CourseStatisticsViewModelFilterOptions.GetFilterOptions(categories, topics);
        }
Exemple #3
0
        public AllCourseStatisticsViewModel(
            IEnumerable <CourseStatistics> courses,
            IEnumerable <string> categories,
            IEnumerable <string> topics
            )
        {
            Courses = courses.Select(c => new SearchableCourseStatisticsViewModel(c));

            Filters = CourseStatisticsViewModelFilterOptions.GetFilterOptions(categories, topics)
                      .SelectAppliedFilterViewModels();
        }