public override Task <GetCommentByIdResponse> GetCommentById(GetCommentByIdRequest request, ServerCallContext context) { try { PostComment.Comment comment = new PostComment.Comment(); var returnValue = comment.GetCommentById(request.Id); var response = new GetCommentByIdResponse { Value = (Comment)returnValue }; return(Task.FromResult(response)); } catch (Exception ex) { _logger.LogError(ex, "Error invoking GetCommentById"); throw new RpcException(new Status(StatusCode.Internal, ex.Message)); } }
public override Task <GetCommentByIdResponse> GetCommentById(GetCommentByIdRequest request, ServerCallContext context) { GetCommentByIdResponse output = new GetCommentByIdResponse(); Comment comment = _context.Comments.Find(request.Id); if (comment != null) { output.Id = request.Id; output.Postid = comment.PostPostId; output.Text = comment.Text; } else { output.Id = request.Id; output.Postid = 0; output.Text = null; } return(Task.FromResult(output)); }
public Task <IActionResult> GetCommentById([FromRoute] GetCommentByIdRequest request) { return(this.HandleRequest <GetCommentByIdRequest, GetCommentByIdResponse>(request)); }