Esempio n. 1
0
        public async Task <IEnumerable <CommentDto> > GetPaginated(long threadId, int page, int perPage)
        {
            var comments = await _context.Comments
                           .TagWith($"{nameof(CommentsRepository)} -> {nameof(GetPaginated)} : {threadId} {page} {perPage}")
                           .Where(c => c.CommentsThreadId == threadId)
                           .OrderByDescending(c => c.DateTime)
                           .Select(CommentMappings.ToCommentDto(_uid))
                           .AsNoTracking()
                           .Paginate(page, perPage)
                           .ToListAsync();

            comments.ForEach(c => c.Body = c.Body is null ? null : Markdown.ToHtml(c.Body, _markdownPipeline));
            return(comments);
        }
Esempio n. 2
0
        public async Task <CommentDto> GetSingle(long id)
        {
            var comment = await _context.Comments
                          .Where(c => c.Id == id)
                          .Select(CommentMappings.ToCommentDto(_uid))
                          .AsNoTracking()
                          .FirstOrDefaultAsync();

            comment.Body = comment.Body is null
                ? null
                : Markdown.ToHtml(comment.Body, _markdownPipeline);

            return(comment);
        }