private void Eliminar_Click(object sender, RoutedEventArgs e)
 {
     if (dtgDatos.SelectedIndex != -1)
     {
         try
         {
             DatosVuelos datosEliminar = dtgDatos.SelectedItem as DatosVuelos;
             cliente.Eliminar(datosEliminar);
             timer.Start();
             txtDestino.Clear();
             txtHora.Clear();
             txtVuelo.Clear();
             cmbEstado.Text        = "";
             dtgDatos.SelectedItem = null;
             Editar.IsEnabled      = false;
             Eliminar.IsEnabled    = false;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         timer.Start();
     }
     else
     {
         MessageBox.Show("Es necesario elegir un elemento para poder eliminarlo.");
     }
 }
        public async void Eliminar(DatosVuelos vuelos)
        {
            var json = JsonConvert.SerializeObject(vuelos);
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Delete, "/Tablero");

            message.Content = new StringContent(json, Encoding.UTF8, "application/json");
            var result = await cliente.SendAsync(message);

            result.EnsureSuccessStatusCode();
        }
 private void dtgDatos_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (dtgDatos.SelectedItem != null)
     {
         Editar.IsEnabled   = true;
         Eliminar.IsEnabled = true;
         timer.Stop();
         datos           = dtgDatos.SelectedItem as DatosVuelos;
         txtHora.Text    = datos.Hora;
         txtDestino.Text = datos.Destino;
         txtVuelo.Text   = datos.Vuelo;
         cmbEstado.Text  = datos.Estado;
     }
 }
        public async void Editar(DatosVuelos vuelos)
        {
            if (vuelos.Estado == "A TIEMPO" || vuelos.Estado == "ABORDANDO" || vuelos.Estado == "CANCELADO" || vuelos.Estado == "RETRASADO")
            {
                var json   = JsonConvert.SerializeObject(vuelos);
                var result = await cliente.PutAsync("/Tablero", new StringContent(json, Encoding.UTF8, "application/json"));

                result.EnsureSuccessStatusCode();
            }
            else
            {
                MessageBox.Show("El vuelo debe tener un estado");
            }
        }