public IActionResult ListarCerveza(int id) { Respuesta oRta = new(); try { using (BasicCrudContext db = new()) { Cerveza oCerveza = db.Cervezas.Find(id); if (oCerveza == null) { oRta.Exito = 0; oRta.Mensaje = "No existe el elemento"; } else { oRta.Exito = 1; oRta.Data = oCerveza; } } } catch (Exception ex) { oRta.Mensaje = ex.Message; } return(Ok(oRta)); }
private void btnAgregar_Click(object sender, EventArgs e) { int capacidadInt = (int)numCapacidad.Value; int contenidoInt = (int)numContenido.Value; Botella botella; string marca = txtMarca.Text; if (btnCerveza.Checked) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbTipo.SelectedValue.ToString(), out tipo); botella = new Cerveza(capacidadInt, marca, tipo, contenidoInt); } else { botella = new Agua(capacidadInt, marca, contenidoInt); } if (botella is Agua) { barra1.AgregarBotella((Agua)botella); } else if (botella is Cerveza) { barra1.AgregarBotella((Cerveza)botella); } }
private void btnAgregar_Click(object sender, EventArgs e) { Botella botella; if (rbCerveza.Checked) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(this.cbTipoBotella.SelectedValue.ToString(), out tipo); botella = new Cerveza((int)this.nudCapacidad.Value, this.txtMarca.Text, tipo, (int)this.nupContenido.Value); this.barra.AgregarBotella(botella); MessageBox.Show(botella.ToString(), "CERVEZA"); } else { if (this.cbTipoBotella.Text == "Plastico") { botella = new Agua((int)this.nudCapacidad.Value, this.txtMarca.Text, (int)this.nupContenido.Value); this.barra.AgregarBotella(botella); MessageBox.Show(botella.ToString(), "AGUA"); } else { MessageBox.Show(" No tenemos agua en envase de vidrio"); } } }
public IActionResult Add(CervezaRequest model) { Respuesta oRespuesta = new Respuesta(); try { using (BlazorCrudContext db = new BlazorCrudContext()) { Cerveza oCerveza = new Cerveza(); oCerveza.Nombre = model.Nombre; oCerveza.Marca = model.Marca; db.Cervezas.Add(oCerveza); db.SaveChanges(); oRespuesta.Exito = 1; } } catch (Exception ex) { //oRespuesta.Mensaje = ex.Message; throw; } return(Ok(oRespuesta)); }
public IActionResult Edit(CervezaRequest model) { Respuesta oRespuesta = new Respuesta(); try { using (BlazorCrudContext db = new BlazorCrudContext()) { Cerveza oCerveza = db.Cervezas.Find(model.Id); if (oCerveza != null) { oCerveza.Nombre = model.Nombre; oCerveza.Marca = model.Marca; db.Entry(oCerveza).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); oRespuesta.Exito = 1; } else { oRespuesta.Mensaje = "La cerveza que desea eliminar no existe"; oRespuesta.Exito = 0; } } } catch (Exception ex) { oRespuesta.Mensaje = ex.Message; } return(Ok(oRespuesta)); }
public IActionResult Delete(int Id) { Respuesta oRespuesta = new Respuesta(); try { using (BlazorCrudContext db = new BlazorCrudContext()) { Cerveza oCerveza = db.Cervezas.Find(Id); if (oCerveza != null) { db.Remove(oCerveza); db.SaveChanges(); oRespuesta.Exito = 1; } else { oRespuesta.Mensaje = "El elemento que busca no pudo ser encontrado"; oRespuesta.Exito = 0; } } } catch (Exception ex) { oRespuesta.Mensaje = ex.Message; } return(Ok(oRespuesta)); }
public ActionResult <Cerveza> Put(int id, [FromBody] Cerveza cerveza) { if (id != cerveza.Id) { return(BadRequest()); } context.Entry(cerveza).State = EntityState.Modified; context.SaveChanges(); return(Ok()); }
public async Task <Cerveza> GetTaskByIdAsync() { HttpClient httpClient = new HttpClient(); var cerveza = await httpClient.GetAsync("https://localhost:44391/api/cervezas"); var response = cerveza.Content.ReadAsStringAsync(); Cerveza cerveza1 = JsonConvert.DeserializeObject <Cerveza>(response.Result); return(cerveza1); }
private void btnAgregar_Click(object sender, EventArgs e) { if (rbAgua.Checked == true) { Agua a1 = new Agua(txtMarca.Text, (int)numberCapacidad.Value, (int)numberContenido.Value); barra1.AgregarBotella(a1); } else { Cerveza c1 = new Cerveza(txtMarca.Text, (int)numberCapacidad.Value, (int)numberContenido.Value); barra1.AgregarBotella(c1); } }
private void btnAgregar_Click(object sender, EventArgs e) { Botella botella = null; if (rBtnAgua.Checked) { botella = new Agua((int)numUpDwCapacidad.Value, txtBoxMarca.Text, (int)numUpDwContenido.Value); } else if (rBtnCerveza.Checked) { botella = new Cerveza((int)numUpDwCapacidad.Value, txtBoxMarca.Text, (Botella.Tipo)cmbBotellaTipo.SelectedValue, (int)numUpDwContenido.Value); } this.barra1.AgregarBotella(botella); }
private void btmAgregar_Click(object sender, EventArgs e) { Enum.TryParse <Botella.Tipo>(cmbBotellaTipo.SelectedValue.ToString(), out tipo); if (rbAgua.Checked == true) { Botella botellaDeAgua = new Agua((int)nudCapacidad.Value, tbMarca.Text, (int)nudContenido.Value); barra1.AgregarBotella(botellaDeAgua); } else if (rbCerveza.Checked == true) { Botella botellaDeCerveza = new Cerveza((int)nudCapacidad.Value, tbMarca.Text, this.tipo, (int)nudContenido.Value); barra1.AgregarBotella(botellaDeCerveza); } }
private void btn_Agregar_Click(object sender, EventArgs e) { if (rdn_Cerveza.Checked) { Botella botellaCerveza = new Cerveza((int)num_Capacidad.Value, (int)num_Contenido.Value, txt_Marca.Text); this.barra.AgregarBotella(botellaCerveza); MessageBox.Show($"{botellaCerveza.ToString()} \nSe agregó la cerveza", "Alcohol", MessageBoxButtons.OK); } else { Botella botellaAgua = new Agua((int)num_Capacidad.Value, (int)num_Contenido.Value, txt_Marca.Text); barra.AgregarBotella(botellaAgua); MessageBox.Show($"{botellaAgua.ToString()} \nSe agregó el agua", "Awita", MessageBoxButtons.OK); } }
private void btnAgregar_Click(object sender, EventArgs e) { if (radioButton1.Checked) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbBotellaTipo.SelectedValue.ToString(), out tipo); Cerveza beer = new Cerveza((int)numericUpDown1.Value, (int)numericUpDown2.Value, tipo, txtMarca.Text); barra.AgregarBotella(beer); } if (radioButton2.Checked) { Agua water = new Agua((int)numericUpDown1.Value, (int)numericUpDown2.Value, txtMarca.Text); barra.AgregarBotella(water); } }
/// <summary> /// Agrega una botella a la barra. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button1_Click(object sender, EventArgs e) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbBotellaTipo.SelectedValue.ToString(), out tipo); if (BtnAgua.Checked) { Agua agua = new Agua((int)numCapacidad.Value, txtMarca.Text, (int)numContenido.Value); barra1.AgregarBotella(agua); } else { Cerveza cerveza = new Cerveza((int)numCapacidad.Value, txtMarca.Text, tipo, (int)numContenido.Value); barra1.AgregarBotella(cerveza); } }
private void btnAgregar_Click(object sender, EventArgs e) { if (rbAgua.Checked) { Agua botellaAgua = new Agua((int)numericUpDown1.Value, txtMarca.Text, (int)numericUpDown2.Value); barra1.AgregarBotella(botellaAgua); } if (rbCerveza.Checked) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbBotellaTipo.SelectedValue.ToString(), out tipo); Cerveza botellaCerveza = new Cerveza((int)numericUpDown1.Value, txtMarca.Text, tipo, (int)numericUpDown2.Value); barra1.AgregarBotella(botellaCerveza); } }
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked) { Botella.Tipo t; Enum.TryParse <Botella.Tipo>(comboBox1.SelectedValue.ToString(), out t); Botella b = new Cerveza(textBox1.Text, (int)numericUpDown1.Value, (int)numericUpDown2.Value, t); barra1.AgregarBotella(b); } else if (radioButton2.Checked) { Botella b = new Agua((int)numericUpDown1.Value, (int)numericUpDown2.Value, textBox1.Text); barra1.AgregarBotella(b); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAgregar_Click(object sender, EventArgs e) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(comboBoxBotellaTipo.SelectedValue.ToString(), out tipo); if (rdioBtnAgua.Checked) { Agua water = new Agua((int)this.numericUpDownCapacidad.Value, this.txtMarca.Text, (int)this.numericUpDownContenido.Value); this.barra1.AgregarBotella(water); } else { Cerveza beer = new Cerveza((int)this.numericUpDownCapacidad.Value, this.txtMarca.Text, (Botella.Tipo)comboBoxBotellaTipo.SelectedItem, (int)this.numericUpDownContenido.Value); this.barra1.AgregarBotella(beer); } }
private void btnAgregar_Click(object sender, EventArgs e) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbBotellaTipo.SelectedValue.ToString(), out tipo); Botella botella = null; if (radioCerveza.Checked) { botella = new Cerveza((int)numericCapacidad.Value, txtMarca.Text, tipo, (int)numericContenido.Value); } if (radioAgua.Checked) { botella = new Agua((int)numericCapacidad.Value, txtMarca.Text, (int)numericContenido.Value); } this.barra.AgregarBotella(botella); }
private void btnAgregar_Click(object sender, EventArgs e) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(comboTipoBotella.SelectedValue.ToString(), out tipo); if (radioCerveza.Checked) { int cap = Convert.ToInt16(numericContenido.Value); Cerveza c = new Cerveza(Convert.ToInt16(numericCapacidad.Value), txtMarca.Text, Convert.ToInt16(numericContenido.Value), tipo); barra1.AgregarBotella(c); } else { Agua a = new Agua(Convert.ToInt16(numericCapacidad.Value), txtMarca.Text, Convert.ToInt16(numericContenido.Value)); barra1.AgregarBotella(a); } }
private void btnAgregar_Click(object sender, EventArgs e) { Botella botella; if (rdbCerbeza.Checked) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbBotellaTipo.SelectedValue.ToString(), out tipo); botella = new Cerveza((int)numContenido.Value, textMarca.Text, (int)numContenido.Value); } else { botella = new Agua((int)numContenido.Value, textMarca.Text, (int)numContenido.Value); } this.barra.AgregarBotella(botella); }
private void btnAgregar_Click(object sender, EventArgs e) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbBotellaTipo.SelectedValue.ToString(), out tipo); if (rbBtnAgua.Checked) { Agua agua = new Agua((int)nudCapacidad.Value, txtMarca.Text, (int)nudContenido.Value); barra.AgregarBotella(agua); MessageBox.Show(agua.toString()); } else if (rdBtnCerveza.Checked) { Cerveza cerveza = new Cerveza((int)nudCapacidad.Value, txtMarca.Text, tipo, (int)nudContenido.Value); barra.AgregarBotella(cerveza); MessageBox.Show(cerveza.toString()); } }
private void button1_Click(object sender, EventArgs e) { string marca = Marca.Text; int capacidad = Convert.ToInt32(Capacidad.Value); int contenido = Convert.ToInt32(Contenido.Value); if (radioButtonAgua.Checked) { Agua a = new Agua(capacidad, marca, contenido); barra.AgregarBotella(a); } if (radioButtonCerveza.Checked) { Cerveza c = new Cerveza(capacidad, marca, tipo, contenido); barra.AgregarBotella(c); } }
private void btnAgregar_Click(object sender, EventArgs e) { Botella botella; if (radioButtonAgua.Checked) { botella = new Agua((int)numCapacidad.Value, txtBoxMarca.Text, (int)numeContenido.Value); barra1.AgregarBotella((Agua)botella); } if (radioButtonCerveza.Checked) { Enum.TryParse <Botella.Tipo>(cmbTipo.SelectedValue.ToString(), out tipo); botella = new Cerveza((int)numCapacidad.Value, txtBoxMarca.Text, tipo, (int)numeContenido.Value); barra1.AgregarBotella((Cerveza)botella); } }
static void Main(string[] args) { Cantina cantina; Cerveza c1 = new Cerveza(1000, "Honey", 500); Cerveza c2 = new Cerveza(2000, "IPA", Botella.Tipo.Plastico, 2050); Agua a = new Agua(500, "Los Andes", 350); Agua a2 = new Agua(500, "Los Andes", 350); cantina = Cantina.GetCantina(3); if (cantina + c1) { c1.ServirMedida(); Console.WriteLine(c1.ToString()); } Console.WriteLine(); if (cantina + c2) { c2.ServirMedida(); Console.WriteLine(c2.ToString()); } Console.WriteLine(); if (cantina + a) { a.ServirMedida(67); Console.WriteLine(a.ToString()); } Console.WriteLine(); if (cantina + a2) { a2.ServirMedida(); Console.WriteLine(a2.ToString()); } Console.ReadKey(); }
public IActionResult EliminarCerveza(int id) { Respuesta oRta = new(); try { using (BasicCrudContext db = new BasicCrudContext()) { Cerveza oCerveza = db.Cervezas.Find(id); db.Remove(oCerveza); db.SaveChanges(); oRta.Exito = 1; } } catch (Exception ex) { oRta.Mensaje = ex.Message; } return(Ok(oRta)); }
/// <summary> /// Agrega botellas a la barra /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAgregar_Click(object sender, EventArgs e) { string marca = txtBoxMarca.Text; int capacidad = (int)numCapacidad.Value; int contenido = (int)numContenido.Value; Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbBoxTipo.SelectedValue.ToString(), out tipo); if (rdBtnCerveza.Checked) { Cerveza c = new Cerveza(capacidad, contenido, marca, tipo); barra.AgregarBotella(c); } else if (rdBtnAgua.Checked) { Agua a = new Agua(capacidad, contenido, marca); barra.AgregarBotella(a); } }
public IActionResult Dele(int Id) { Respuesta oRespuesta = new Respuesta(); try { using (BlazorCrudContext db = new BlazorCrudContext()) { Cerveza oCerveza = db.Cervezas.Find(Id); db.Remove(oCerveza); db.SaveChanges(); oRespuesta.Exito = 1; } } catch (Exception ex) { oRespuesta.Mensaje = ex.Message; } return(Ok(oRespuesta)); }
private void btnAgregar_Click(object sender, EventArgs e) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbBotellaTipo.SelectedValue.ToString(), out tipo); if (rdbtnAgua.Checked) { Agua agua = new Agua(Convert.ToInt32(nupdoCapacidad.Value), txtbMarca.Text, Convert.ToInt32(numericUpDown2.Value)); this.barra1.AgregarBotella(agua); } else if (rdbtnCerveza.Checked) { Cerveza cerveza = new Cerveza(Convert.ToInt32(nupdoCapacidad.Value), txtbMarca.Text, tipo, Convert.ToInt32(numericUpDown2.Value)); this.barra1.AgregarBotella(cerveza); } else { MessageBox.Show("Seleccione cerveza o agua"); } }
private void btnAgregar_Click(object sender, EventArgs e) { Botella.Tipo tipo; Enum.TryParse <Botella.Tipo>(cmbTipo.SelectedValue.ToString(), out tipo); if (rBtnAgua.Checked) { Agua botellaAgua = new Agua(txtMarca.Text, (int)numCapacidad.Value, (int)numContenido.Value); this.barra.AgregarBotella(botellaAgua); } else if (rBtnCerveza.Checked) { Cerveza botellaCerveza = new Cerveza(txtMarca.Text, (int)numCapacidad.Value, (int)numContenido.Value, tipo); this.barra.AgregarBotella(botellaCerveza); } else { MessageBox.Show("seleccione tipo"); } }
private void btnAgregar_Click(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(txtMarca.Text)) { if (rbAgua.Checked) { Agua dasani = new Agua((int)nudCapacidad.Value, txtMarca.Text, (int)nudContenido.Value); this.barra1.AgregarBotella(dasani); //MessageBox.Show("Agua Agregada!", "Suceso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Cerveza andes = new Cerveza((int)nudCapacidad.Value, txtMarca.Text, (Botella.Tipo)cmbBotellaTipo.SelectedIndex, (int)nudContenido.Value); this.barra1.AgregarBotella(andes); //MessageBox.Show("Birrita Agregada!", "Suceso", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Hay campos vacios", "Cuidado!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }