public ActionResult GetPendingComments(int page = 1, int size = 10) { List <CommentOutputDto> list = CommentBll.LoadPageEntities <DateTime, CommentOutputDto>(page, size, out int total, c => c.Status == Status.Pending, c => c.CommentDate, false).ToList(); var pageCount = Math.Ceiling(total * 1.0 / size).ToInt32(); return(PageResult(list, pageCount, total)); }
public ActionResult GetPageComments(int page = 1, int size = 5, int cid = 0) { UserInfoOutputDto user = Session.GetByRedis <UserInfoOutputDto>(SessionKey.UserInfo) ?? new UserInfoOutputDto(); int total; //总条数,用于前台分页 if (cid != 0) { int pid = CommentBll.GetParentCommentIdByChildId(cid); List <Comment> single = CommentBll.GetSelfAndAllChildrenCommentsByParentId(pid).ToList(); if (single.Any()) { total = 1; return(ResultData(new { total, parentTotal = total, page, size, rows = single.Mapper <IList <CommentViewModel> >() })); } } IList <Comment> parent = CommentBll.LoadPageEntities(page, size, out total, c => c.ParentId == 0 && (c.Status == Status.Pended || user.IsAdmin), c => c.CommentDate, false).ToList(); if (!parent.Any()) { return(ResultData(null, false, "没有评论")); } var list = new List <Comment>(); parent.ForEach(c => CommentBll.GetSelfAndAllChildrenCommentsByParentId(c.Id).ForEach(result => list.Add(result))); var qlist = list.Where(c => (c.Status == Status.Pended || user.IsAdmin)); if (total > 0) { return(ResultData(new { total, parentTotal = total, page, size, rows = qlist.Mapper <IList <CommentViewModel> >() })); } return(ResultData(null, false, "没有评论")); }