private IQueryable <Comment> Filter(CommentPaginationParams pageParams) { return(FindByExpression(comment => comment.CreatedDate > pageParams.MinDateTime && comment.CreatedDate < pageParams.MaxDateTime && (string.IsNullOrEmpty(pageParams.BookId) || comment.BookId == pageParams.BookId) && (string.IsNullOrEmpty(pageParams.UserId) || comment.senderId == pageParams.UserId))); }
public static CommentPaginationParams ConvertToCommentPagination(this CommentPaginationParams _params, HttpContext context) { _params.UserId = context.User.FindFirst(ClaimTypes.NameIdentifier).Value; _params.BookId = context.Request.Headers["BookId"]; return(_params); }
public async Task <PagedList <Comment> > GetCommentPerPage(CommentPaginationParams pageParams) { IQueryable <Comment> filteredSource = Filter(pageParams).Include(c => c.Sender); return(await PagedList <Comment> .ToPagedList(filteredSource, pageParams.Pagenumber, pageParams.Pagesize)); }