Example #1
0
        public void GetGroupCoursesForCategory_filters_courses_by_category()
        {
            // Given
            var correctCategoryCourse   = GroupTestHelper.GetDefaultGroupCourse();
            var incorrectCategoryCourse = GroupTestHelper.GetDefaultGroupCourse(
                2,
                courseCategoryId: 255
                );

            A.CallTo(() => groupsDataService.GetGroupCoursesForCentre(1)).Returns(
                new[]
            {
                correctCategoryCourse,
                incorrectCategoryCourse,
            }
                );

            // When
            var result = groupsService.GetGroupCoursesForCategory(8, 1, 1).ToList();

            // Then
            result.Should().Contain(correctCategoryCourse);
            result.Should().NotContain(incorrectCategoryCourse);
        }
Example #2
0
        public IActionResult GroupCourses(int groupId, int page = 1)
        {
            var centreId  = User.GetCentreId();
            var groupName = groupsService.GetGroupName(groupId, centreId);

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

            var categoryIdFilter = User.GetAdminCourseCategoryFilter();

            var groupCourses = groupsService.GetGroupCoursesForCategory(groupId, centreId, categoryIdFilter);

            var model = new GroupCoursesViewModel(groupId, groupName, groupCourses, page);

            return(View(model));
        }
        public IActionResult Index(int groupId, int page = 1)
        {
            var centreId  = User.GetCentreId();
            var groupName = groupsService.GetGroupName(groupId, centreId);

            var categoryIdFilter = User.GetAdminCourseCategoryFilter();

            var groupCourses = groupsService.GetGroupCoursesForCategory(groupId, centreId, categoryIdFilter);

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

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

            return(View(model));
        }