示例#1
0
 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));
     }
 }
示例#2
0
        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));
        }
示例#3
0
 public Task <IActionResult> GetCommentById([FromRoute] GetCommentByIdRequest request)
 {
     return(this.HandleRequest <GetCommentByIdRequest, GetCommentByIdResponse>(request));
 }