コード例 #1
0
 public ActionResult <CollectionWithPaginationData <PostCommentDto> > GetComments(string postId, [FromQuery] PaginationParams paginationParams)
 {
     try
     {
         if (Guid.TryParse(postId, out Guid gPostId))
         {
             if (_postService.CheckIfPostExists(gPostId))
             {
                 PagedList <PostCommentDto> commentsToReturn = _postCommentService.GetPostComments(gPostId, paginationParams);
                 return(Ok(this.CreateCollectionWithPagination(commentsToReturn, paginationParams, "GetComments")));
             }
             else
             {
                 return(NotFound($"Post: {postId} not found."));
             }
         }
         else
         {
             return(BadRequest($"{postId} is not valid guid."));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error occured during getting comments of the post: {postId}", postId);
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
コード例 #2
0
 public async Task <IActionResult> GetPostComments(Guid id)
 {
     return(Ok(await _commentForPostService.GetPostComments(id)));
 }