private static PaginationModel <ImageLikesModel> BuildEditPaginationModel <TFinder>
            (PaginationService <Picture, TFinder> pagination,
            int pageNumber, int userId)
            where TFinder : PaginationFinder <Picture>
        {
            var pictures = pagination.GetPageObjects(pageNumber);

            var models = new List <ImageLikesModel>(12);

            var dao = new VoteFindDao();

            var ownerDao = new VoteOwnerDao();

            models.AddRange(pictures.Select(picture => new ImageLikesModel
            {
                VotesModel = new VotesModel
                {
                    Dislikes = dao.GetDislikesVoteCount(picture.PictureId),
                    Likes    = dao.GetLikesVoteCount(picture.PictureId),
                    IsOwner  = ownerDao.CheckOwner(userId, picture.PictureId)
                },
                ImageModel = new ImageEditModel
                {
                    PictureUrl = picture.PictureUrl, PictureId = picture.PictureId
                }
            }));


            return(new PaginationModel <ImageLikesModel>
            {
                ObjectsList = models,
                PagesCount = pagination.GetPagesCount(),
                PageNumber = pageNumber
            });
        }
Beispiel #2
0
        private string BuildTableWithPagination(List <LaunchInfo> launches, CacheContentType contentType, int currentPage)
        {
            var itemsToDisplay = _paginationService.GetItemsToDisplay(launches, currentPage);

            itemsToDisplay = itemsToDisplay.OrderBy(p => p.DateUtc ?? DateTime.MinValue).ToList();

            var maxPagesCount    = _paginationService.GetPagesCount(launches.Count);
            var paginationFooter = _paginationService.GetPaginationFooter(currentPage, maxPagesCount);

            return(_launchesListTableGenerator.Build(itemsToDisplay, contentType, currentPage, paginationFooter));
        }
Beispiel #3
0
        private string BuildTableWithPagination(List <CoreInfo> cores, int currentPage)
        {
            cores.Sort(CoreLaunchDateComparer);

            var itemsToDisplay = _paginationService.GetItemsToDisplay(cores, currentPage);

            var maxPagesCount    = _paginationService.GetPagesCount(cores.Count);
            var paginationFooter = _paginationService.GetPaginationFooter(currentPage, maxPagesCount);

            return(_coresListTableGenerator.Build(itemsToDisplay, currentPage, paginationFooter));
        }
Beispiel #4
0
        public ActionResult ViewNews(int id = 0)
        {
            if (!_pagination.IsCorrectRequest(id))
            {
                return(HttpNotFound());
            }

            ViewBag.pageNumber = id;
            ViewBag.pagesCount = _pagination.GetPagesCount();

            IEnumerable <News> news = _pagination.GetNewsBlock(id);

            return(View(news));
        }
Beispiel #5
0
        public ActionResult Index(int id = 0)
        {
            if (!_pagination.IsCorrectRequest(id))
            {
                return(HttpNotFound());
            }

            ViewBag.pageNumber = id;
            ViewBag.pagesCount = _pagination.GetPagesCount();
            ViewBag.randomNews = _randomNews.GetRandomNews();

            List <News> news = _pagination.GetNewsBlock(id);

            return(View(news));
        }
        private static PaginationModel <ImageReadModel> BuildReadPaginationModel <TFinder>
            (PaginationService <Picture, TFinder> pagination,
            int pageNumber)
            where TFinder : PaginationFinder <Picture>
        {
            var pictures = pagination.GetPageObjects(pageNumber);

            var images = pictures.Select(picture => new ImageReadModel {
                PictureUrl = picture.PictureUrl
            }).ToList();

            return(new PaginationModel <ImageReadModel>
            {
                ObjectsList = images,
                PagesCount = pagination.GetPagesCount(),
                PageNumber = pageNumber
            });
        }