Пример #1
0
        public GetCommentsResponse GetCommentsByParentComment(GetCommentsByParentCommentRequest request)
        {
            GetCommentsResponse response = new GetCommentsResponse();

            response.StatusCode = 200;
            response.Errors     = new List <string>();
            var comments           = _commentRepository.GetByParentCommentId(request.PostId, request.ParentCommentId);
            List <CommentDTO> dtos = new List <CommentDTO>();

            foreach (var comment in comments)
            {
                CommentDTO dto = new CommentDTO()
                {
                    Comment     = comment,
                    Username    = _userRepository.GetUserById(comment.UserId).Username,
                    SubComments = _commentRepository.GetByParentCommentId(comment.PostId, comment.Id).Count,
                };
                dtos.Add(dto);
            }
            response.Comments = dtos;
            return(response);
        }
 public JsonResult GetByComment([FromQuery] GetCommentsByParentCommentRequest request)
 {
     return(Json(_commentService.GetCommentsByParentComment(request)));
 }