public static async Task<HttpResponseMessage> Delete(Manufacturer manufacturer) { using (var c = APIService.GetClient()) { return await c.DeleteAsync($"manufacturers/{manufacturer.Id}"); } }
private async void buttonAdd_Click(object sender, RoutedEventArgs e) { string description = textBoxDescription.Text.Trim(); if (!String.IsNullOrEmpty(description)) { Manufacturer manufacturer = new Manufacturer() { Description = description }; HttpResponseMessage response = await Manufacturer.Add(manufacturer); if (response.IsSuccessStatusCode) { InitDataGrid(); ClearFields(); MessageBox.Show($"Manufacturer {manufacturer.Description} was added"); } else { MessageBox.Show($"Manufacturer {manufacturer.Description} wasn't added"); } } else { MessageBox.Show("Enter a description..."); } }
public static async Task<HttpResponseMessage> Edit(Manufacturer manufacturer) { using (var c = APIService.GetClient()) { string json = JsonConvert.SerializeObject(manufacturer); StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); return await c.PutAsync($"manufacturers/{manufacturer.Id}", content); } }