예제 #1
0
 public static void guardarVuelo(VuelosForm vuelo)
 {
     using (var ctx = new VuelosEntities1())
     {
         using (var dbContextTransaction = ctx.Database.BeginTransaction())
         {
             try
             {
                 Vuelo v = new Vuelo();
                 v.NumeroDeVuelo  = vuelo.numeroDeVuelo;
                 v.HorarioLlegada = vuelo.horaLlegada;
                 v.Demorado       = vuelo.demorado;
                 v.IDLineaAerea   = vuelo.lineaAerea;
                 ctx.Vuelo.Add(v);
                 ctx.SaveChanges();
                 dbContextTransaction.Commit();
             }
             catch (Exception e)
             {
                 dbContextTransaction.Rollback();
                 throw e;
             }
         }
     }
 }
예제 #2
0
 public static void eliminarVuelo(int id)
 {
     using (var ctx = new VuelosEntities1())
     {
         using (var dbContextTransaction = ctx.Database.BeginTransaction())
         {
             try
             {
                 var v = ctx.Vuelo.Find(id);
                 ctx.Vuelo.Remove(v);
                 ctx.SaveChanges();
                 dbContextTransaction.Commit();
             }
             catch (Exception e)
             {
                 dbContextTransaction.Rollback();
                 throw e;
             }
         }
     }
 }