public override Task <UpdateCommentResponse> UpdateComment(UpdateCommentRequest request, ServerCallContext context) { try { PostComment.Comment comment = new PostComment.Comment(); var returnValue = comment.UpdateComment((global::PostComment.Comment)request.NewComment); var response = new UpdateCommentResponse { Value = (Comment)returnValue }; return(Task.FromResult(response)); } catch (Exception ex) { _logger.LogError(ex, "Error invoking UpdateComment"); throw new RpcException(new Status(StatusCode.Internal, ex.Message)); } }
public override Task <UpdateCommentResponse> UpdateComment(UpdateCommentRequest request, ServerCallContext context) { UpdateCommentResponse output = new UpdateCommentResponse(); Comment oldComment = _context.Comments.Find(request.Id); if (request.Text != null) { oldComment.Text = request.Text; } if ((oldComment.PostPostId != request.Postid) && (request.Postid != 0)) { oldComment.PostPostId = request.Postid; } _context.SaveChanges(); output.Id = oldComment.CommentId; return(Task.FromResult(output)); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { UpdateCommentResponse response = new UpdateCommentResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("comment", targetDepth)) { var unmarshaller = CommentUnmarshaller.Instance; response.Comment = unmarshaller.Unmarshall(context); continue; } } return(response); }