예제 #1
0
 public ActionResult <List <PostCommentDto> > GetComment(string postId, string commentId)
 {
     try
     {
         if (Guid.TryParse(postId, out Guid gPostId) && Guid.TryParse(commentId, out Guid gCommentId))
         {
             if (_postService.CheckIfPostExists(gPostId))
             {
                 return(Ok(_postCommentService.GetComment(gCommentId)));
             }
             else
             {
                 return(NotFound($"Post: {postId} not found."));
             }
         }
         else
         {
             return(BadRequest($"{postId} or {commentId} is not valid guid."));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error occured during getting comment: postId: {postId}, commentId: {commentId}", postId, commentId);
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }