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)); } }
public async Task <IActionResult> GetPostComments(Guid id) { return(Ok(await _commentForPostService.GetPostComments(id))); }