public async Task GuardarEnInventario(RepositorioAPIInventario Articulos, string ruta, bool isNewItem = false) { Uri RutaFormateada = new Uri(string.Format(ruta, string.Empty)); string json = JsonConvert.SerializeObject(Articulos, Formatting.Indented); StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); try { HttpResponseMessage responseMessage = null; if (isNewItem) { responseMessage = await _cliente.PostAsync(RutaFormateada, content); } if (responseMessage.IsSuccessStatusCode) { Debug.WriteLine(@"\tArticulo agregado correctamente."); } } catch { throw; } }
private async void BtnAdd_Clicked(object sender, EventArgs e) { RepositorioAPIInventario Articulo = new RepositorioAPIInventario { Descripcion_P = EntName.Text, Cantidad_S = int.Parse(EntCantidad.Text), Precio_V = int.Parse(EntPrecio.Text), Fecha_C = FechaCompra.Date, Fecha_E = FechaExpiraccion.Date }; await restServicios.GuardarEnInventario(Articulo, constantes.APIInventarioURL, true); await Navigation.PopModalAsync(); }