async protected void btnModificar_Click(object sender, EventArgs e) { try { if (ValidarInsertar() && (!string.IsNullOrEmpty(txtCodigo.Text))) { Models.Aerolinea aerolineaModificada = new Models.Aerolinea(); Models.Aerolinea aerolinea = new Models.Aerolinea() { AER_CODIGO = Convert.ToInt32(txtCodigo.Text), AER_NOMBRE = txtNombre.Text, AER_EMAIL = txtEmail.Text, AER_PAIS = txtPais.Text, AER_TELEFONO = txtTelefono.Text }; aerolineaModificada = await aerolineaManager.Actualizar(aerolinea, Session["TokenUsuario"].ToString()); if (aerolineaModificada != null) { lblResultado.Text = "Aerolínea actualizada correctamente"; lblResultado.ForeColor = Color.Green; lblResultado.Visible = true; InicializarControles(); } else { lblResultado.Text = "Error al actualizar aerolínea"; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } } else { lblResultado.Text = "Debe ingresar todos los datos"; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } } catch (Exception ex) { lblResultado.Text = "Hubo un error al actualizar la aerolínea. Detalle: " + ex.Message; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } }
async protected void btnIngresar_Click(object sender, EventArgs e) { try { if (ValidarInsertar()) { Models.Aerolinea aerolineaIngresada = new Models.Aerolinea(); Models.Aerolinea aerolinea = new Models.Aerolinea() { AER_NOMBRE = txtNombre.Text, AER_EMAIL = txtEmail.Text, AER_PAIS = txtPais.Text, AER_TELEFONO = txtTelefono.Text }; aerolineaIngresada = await aerolineaManager.Ingresar(aerolinea, Session["TokenUsuario"].ToString()); if (aerolineaIngresada != null) { lblResultado.Text = "Aerolínea ingresada orrectamente"; lblResultado.ForeColor = Color.Green; lblResultado.Visible = true; InicializarControles(); } else { lblResultado.Text = "Error al crear aerolínea"; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } } } catch (Exception exc) { lblResultado.Text = "Hubo un error al ingresar la aerolínea. Detalle: " + exc.Message; lblResultado.ForeColor = Color.Maroon; lblResultado.Visible = true; } }