public Task <T> PostAsync <T>(IReturn <T> request) { _logger.Maybe(() => _logger.LogMessage("CMT Post : " + request.ToJson())); var result = Client.PostAsync(request); result.ContinueWith(r => LogResult(r, "CMT Post Result: ")); return(result); }
public static Task <TResponse> PostAsync <TResponse>(this ServiceClientBase client, IReturn <TResponse> request) { var tcs = new TaskCompletionSource <TResponse>(); client.PostAsync <string>(request.ToUrl(HttpMethods.Post, client.Format), request, result => { var dto = Newtonsoft.Json.JsonConvert.DeserializeObject <TResponse>(result); tcs.SetResult(dto); }, (response, exception) => { Log.Debug("CMT Response Body : " + response + Environment.NewLine + Environment.NewLine + "Request : " + client.BaseUri + request.ToUrl(HttpMethods.Post, client.Format) + Environment.NewLine + request.ToJson() + Environment.NewLine + Environment.NewLine + "Exception : " + LogException(exception)); tcs.SetException(FixWebServiceException(exception)); } ); return(tcs.Task); }