diff --git a/src/ReC.Client/Api/BaseCrudApi.cs b/src/ReC.Client/Api/BaseCrudApi.cs index cce0594..c5f450d 100644 --- a/src/ReC.Client/Api/BaseCrudApi.cs +++ b/src/ReC.Client/Api/BaseCrudApi.cs @@ -37,9 +37,15 @@ namespace ReC.Client.Api /// The payload type. /// The payload to send. /// A token to cancel the operation. - /// The HTTP response message. - public Task CreateAsync(T payload, CancellationToken cancel = default) - => Http.PostAsync(ResourcePath, ReCClientHelpers.ToJsonContent(payload), cancel); + /// if the request succeeds; otherwise, . + public async Task CreateAsync(T payload, CancellationToken cancel = default) + { + using (var content = ReCClientHelpers.ToJsonContent(payload)) + using (var resp = await Http.PostAsync(ResourcePath, content, cancel)) + { + return resp.IsSuccessStatusCode; + } + } /// /// Updates a resource by identifier. @@ -48,9 +54,15 @@ namespace ReC.Client.Api /// The resource identifier. /// The payload to send. /// A token to cancel the operation. - /// The HTTP response message. - public Task UpdateAsync(long id, T payload, CancellationToken cancel = default) - => Http.PutAsync($"{ResourcePath}/{id}", ReCClientHelpers.ToJsonContent(payload), cancel); + /// if the request succeeds; otherwise, . + public async Task UpdateAsync(long id, T payload, CancellationToken cancel = default) + { + using (var content = ReCClientHelpers.ToJsonContent(payload)) + using (var resp = await Http.PutAsync($"{ResourcePath}/{id}", content, cancel)) + { + return resp.IsSuccessStatusCode; + } + } /// /// Deletes resources with identifiers supplied in the payload. @@ -58,14 +70,17 @@ namespace ReC.Client.Api /// The payload type containing identifiers. /// The payload to send. /// A token to cancel the operation. - /// The HTTP response message. - public Task DeleteAsync(T payload, CancellationToken cancel = default) + /// if the request succeeds; otherwise, . + public async Task DeleteAsync(T payload, CancellationToken cancel = default) { - var request = new HttpRequestMessage(HttpMethod.Delete, ResourcePath) + using (var request = new HttpRequestMessage(HttpMethod.Delete, ResourcePath) { Content = ReCClientHelpers.ToJsonContent(payload) - }; - return Http.SendAsync(request, cancel); + }) + using (var resp = await Http.SendAsync(request, cancel)) + { + return resp.IsSuccessStatusCode; + } } } }