Exemplo n.º 1
0
 public static async Task<HttpResponseMessage> Delete(Manufacturer manufacturer)
 {
     using (var c = APIService.GetClient())
     {
         return await c.DeleteAsync($"manufacturers/{manufacturer.Id}");
     }
 }
Exemplo n.º 2
0
 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...");
     }
 }
Exemplo n.º 3
0
 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);
     }
 }