示例#1
0
        public PagedResponse <PostCommentDto, Comment> Execute(PostCommentSearch search)
        {
            if (_context.Posts.Find(search.PostId) == null)
            {
                throw new EntityNotFoundException(search.PostId, typeof(Post));
            }

            // show only parent comments and they will show information of number of child comments that will be accessable thorugh anotehr action (show all replies to comment)
            var query = _context.Comments.Include(c => c.ChildComments).Where(c => c.PostId == search.PostId && c.ParentId == null).AsQueryable();

            return(new PagedResponse <PostCommentDto, Comment>(query, search, _mapper));
        }
 public IActionResult GetCommentsForPost(int id, PostCommentSearch search, [FromServices] IGetPostCommentsQuery query)
 {
     search.PostId = id;
     return(Ok(_executor.ExecuteQuery(query, search)));
 }