public static async Task <string> AgregarInventario(Inventario_TR inventario) { HttpClient client = new HttpClient { BaseAddress = new Uri("http://localhost:55979/") }; var request = client.PostAsync("api/Inventario", inventario, new JsonMediaTypeFormatter()).Result; if (request.IsSuccessStatusCode) { return("Registro realizado correctamente"); } return(request.Content.ReadAsStringAsync().Result); }
private async void btnAgregarInven_Click(object sender, RoutedEventArgs e) { try { var nombre = txtNombreInven.Text; var descripcion = txtDescripInven.Text; Inventario_TR inventario = new Inventario_TR(nombre, descripcion); var res = await ComicProcessor.AgregarInventario(inventario); if (res != String.Empty) { MessageBox.Show(res.ToString()); } } catch (Exception eX) { MessageBox.Show(eX.ToString()); } }