private async void btnPut_Click(object sender, EventArgs e) { //Inicialización de variables int idplato = Convert.ToInt32(txtID.Text); string nombreplato = txtNombre.Text; int valor = Convert.ToInt32(txtValor.Text); int tiempo = Convert.ToInt32(txtTiempo.Text); string preparacion = txtPreparacion.Text; int id = Convert.ToInt32((cmbCategoria.SelectedItem as ComboboxItem).Value.ToString()); //Realización metodo PUT var responce = await RestHelperPlato.Put(idplato, nombreplato, valor, tiempo, preparacion, id); //txtResponce.Text = RestHelperPlato.BeautifyJson(responce); }
private async void Recetas_Load(object sender, EventArgs e) { string respuesta = await GetHttp(); List <Receta> lst = JsonConvert.DeserializeObject <List <Receta> >(respuesta); var nuevalista = lst.Select(x => new { Id_Receta = x.idReceta, Cantidad_Producto = x.cantidadReceta, Producto = (x.producto == null ? "": x.producto.nombreProducto), Plato = (x.plato == null ? "": x.plato.nombrePlato), Preparacion = x.plato.prepPlato }).ToList(); dtgReceta.DataSource = nuevalista; var respuestass = await RestHelper.GetAll(); dynamic miarray = JsonConvert.DeserializeObject(respuestass); // Recorremos el array de datos del JSON foreach (var item in miarray) { ComboboxItem item2 = new ComboboxItem { Text = item.nombreProducto, Value = item.idProducto }; cmbProducto.Items.Add(item2); cmbProducto.SelectedIndex = 0; } var respuestasa = await RestHelperPlato.GetAll(); dynamic miarray2 = JsonConvert.DeserializeObject(respuestasa); // Recorremos el array de datos del JSON foreach (var item3 in miarray2) { ComboboxItem item4 = new ComboboxItem { Text = item3.nombrePlato, Value = item3.idPlato }; cmbPlato.Items.Add(item4); cmbPlato.SelectedIndex = 0; } }
private async void btnGet_Click(object sender, EventArgs e) { // string resp = await GetHttp(); int id = Convert.ToInt32(txtID.Text); var resonce = await RestHelperPlato.Get(id); List <Plato> lst = JsonConvert.DeserializeObject <List <Plato> >(resonce); var nuevalista = lst.Select(x => new { ID = x.idPlato, Nombre_Plato = x.nombrePlato, Valor = x.valorPlato, Tiempo = x.tiempoPlato, Preparacion = x.prepPlato, Categoria = x.categoria.nombreCategoria }).ToList(); dtgLoad.DataSource = nuevalista; }
private async void btnPost_Click(object sender, EventArgs e) { try { //Inicialización de variables string nombreplato = txtNombre.Text; int valor = Convert.ToInt32(txtValor.Text); int tiempo = Convert.ToInt32(txtTiempo.Text); string preparacion = txtPreparacion.Text; int id = Convert.ToInt32((cmbCategoria.SelectedItem as ComboboxItem).Value.ToString()); //Realización metodo POST var responce = await RestHelperPlato.Post(nombreplato, valor, tiempo, preparacion, id); //txtResponce.Text = RestHelperPlato.BeautifyJson(responce); } catch (Exception) { MessageBox.Show("ingrese los datos faltantes"); }//Inicialización de variables }