예제 #1
0
        public async Task <IActionResult> Single()
        {
            var serviceModel = await this.videoService
                               .GetAllPagination(1);

            var viewModel = new VideoPaginationViewModel()
            {
                Videos = serviceModel.Select(a => AutoMapperConfig.MapperInstance.Map <VideoViewModel>(a))
                         .ToList(),
                PagesCount  = 1,
                CurrentPage = 1,
            };

            return(this.View("All", viewModel));
        }
예제 #2
0
        public async Task <IActionResult> All(int page = 1)
        {
            var serviceModel = await this.videoService
                               .GetAllPagination(VideosPerPage, (page - 1) *VideosPerPage);

            var pagesCount = (int)Math.Ceiling(this.videoService.GetAll().Count() / (decimal)VideosPerPage);
            var viewModel  = new VideoPaginationViewModel()
            {
                Videos = serviceModel.Select(a => AutoMapperConfig.MapperInstance.Map <VideoViewModel>(a))
                         .ToList(),
                PagesCount  = pagesCount == 0 ? 1 : pagesCount,
                CurrentPage = page,
            };

            return(this.View(viewModel));
        }
예제 #3
0
        public async Task <IActionResult> Video(int page, string searchTerm)
        {
            var serviceModel = await this.searchService
                               .GetVideos(searchTerm, VideosPerPage, (page - 1) *VideosPerPage);

            var pagesCount = (int)Math.Ceiling(serviceModel.VideosCount / (decimal)VideosPerPage);

            var viewModel = new VideoPaginationViewModel
            {
                Videos      = serviceModel.Videos.Select(v => AutoMapperConfig.MapperInstance.Map <VideoViewModel>(v)).ToList(),
                PagesCount  = pagesCount == 0 ? 1 : pagesCount,
                CurrentPage = page,
            };

            return(this.View(viewModel));
        }