public async Task RemovePhotos(Guid itemId, string concurrencyId, Uri removed) { try { using (var client = new HttpClient()) { var resource = new Uri(this.ItemsResource, $"{ itemId }"); var payload = new { Id = itemId.ToString(), ConcurrencyId = concurrencyId, Photo = removed }; var content = new StringContent(JsonConvert.SerializeObject(payload), Encoding.UTF8, "application/json"); content.Headers.ContentType.Parameters.Add(new NameValueHeaderValue("domain-model", "RemovePhotoCommand")); var response = await InventoryClient.PutWithTimeoutAsync(resource, content, client); InventoryClient.ThrowExceptionOnError(response); } } catch (TaskCanceledException e) { InventoryClient.ThrowTimeoutException(e); } }
public async Task SaveItemAsync(Item update) { try { using (var client = new HttpClient()) { var resource = new Uri(this.ItemsResource, $"{ update.Id }"); var content = new StringContent(JsonConvert.SerializeObject(update), Encoding.UTF8, "application/json"); content.Headers.ContentType.Parameters.Add(new NameValueHeaderValue("domain-model", "UpdateItemCommand")); var response = await InventoryClient.PutWithTimeoutAsync(resource, content, client); InventoryClient.ThrowExceptionOnError(response); } } catch (TaskCanceledException e) { InventoryClient.ThrowTimeoutException(e); } }