Beispiel #1
0
 public static void Create(DetallePedido p)
 {
     using (DeliveryJWEntities db = new DeliveryJWEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.DetallePedido.Add(p);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 throw;
             }
         }
     }
 }
Beispiel #2
0
 public static void Delete(int?id)
 {
     using (DeliveryJWEntities db = new DeliveryJWEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 DetallePedido p = db.DetallePedido.Find(id);
                 db.Entry(p).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Beispiel #3
0
 public static void Update(DetallePedido p)
 {
     using (DeliveryJWEntities db = new DeliveryJWEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.DetallePedido.Attach(p);
                 db.Entry(p).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }