示例#1
0
        public async Task <IActionResult> Archive(string searchTerm, int currentPage = 1)
        {
            var pagination = new PaginationViewModel
            {
                SearchTerm    = searchTerm,
                Action        = nameof(Archive),
                RequestedPage = currentPage,
                TotalItems    = await this.courseService.TotalArchivedAsync(searchTerm)
            };

            var search = new SearchViewModel
            {
                Controller  = WebConstants.CoursesController,
                Action      = nameof(Archive),
                SearchTerm  = searchTerm,
                Placeholder = WebConstants.SearchByCourseName
            };

            var courses = await this.courseService.AllArchivedAsync(searchTerm, pagination.CurrentPage, WebConstants.PageSize);

            var model = new CoursePageListingViewModel
            {
                Courses    = courses,
                Pagination = pagination,
                Search     = search
            };

            return(this.View(model));
        }
        private void AssertCoursePage(PaginationViewModel testPagination, CoursePageListingViewModel model)
        {
            Assert.NotNull(model);

            Tests.AssertCourseServiceModelCollection(model.Courses);
            //Tests.AssertSearchViewModel(TestSearchTerm, model.Search); // TODO
            Tests.AssertPagination(testPagination, model.Pagination);

            Assert.Equal(nameof(TrainersController.Courses), model.Pagination.Action);
        }