Exemplo n.º 1
0
        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
            });
        }
Exemplo n.º 2
0
        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
            });
        }