示例#1
0
        public PaginationComment ListPage(Pagination pagination, IOrderedQueryable <comment> comments)
        {
            int page = pagination.Page;
            int size = pagination.Size;

            if (page < 1)
            {
                page = 1;
            }

            int skip = (page - 1) * size;

            int sizePage = comments.Count();

            if (sizePage % size > 0)
            {
                sizePage = sizePage / size + 1;
            }
            else
            {
                sizePage = sizePage / size;
            }

            var sql = comments.Skip(skip).Take(size).ToList();

            PaginationComment paginationComment = new PaginationComment(sizePage, page, sql);

            return(paginationComment);
        }
示例#2
0
        public PaginationComment ListHide(Pagination pagination)
        {
            var list = WcDbContext.comments.Where(comment => comment.StatusCommentId == 2)
                       .OrderByDescending(comment => comment.CommentTime);

            PaginationComment paginationComment = ListPage(pagination, list);

            return(paginationComment);
        }
示例#3
0
        public PaginationComment List(Pagination pagination, int chapterId)
        {
            var list = WcDbContext.comments
                       .Where(comment => comment.StatusCommentId == 1 && comment.ChapterId == chapterId &&
                              comment.user.StatusUserId == 1)
                       .OrderByDescending(comment => comment.CommentTime);

            PaginationComment paginationComment = ListPage(pagination, list);

            return(paginationComment);
        }