public async Task <IEnumerable <CommentDto> > Handle(GetPostCommentsQuery request, CancellationToken cancellationToken)
        {
            var commentsDtos = await _unitOfWork.Comments
                               .Include(c => c.Person)
                               .Where(c => c.PostId == request.PostId)
                               .OrderByDescending(c => c.CreatedAt)
                               .Select(c => _mapper.Map <CommentDto>(c))
                               .ToListAsync();

            return(commentsDtos);
        }
Exemplo n.º 2
0
 public async Task <ActionResult <IEnumerable <GetPostCommentOutputModel> > > GetPostComments(
     [FromRoute] GetPostCommentsQuery query)
 => await this.Send(query);
Exemplo n.º 3
0
 public async Task <List <Comment> > HandleAsync(GetPostCommentsQuery query)
 {
     return(await _db.Comments.AsQueryable()
            .Where(c => c.PostId == query.PostId).ToListAsync());
 }