Exemplo n.º 1
0
 public static void Update(Usuario usuario)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Usuario.Attach(usuario);
                 db.Entry(usuario).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
             }
         }
     }
 }
Exemplo n.º 2
0
 public static void Create(Carrito a)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Carrito.Add(a);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Exemplo n.º 3
0
 public static void Delete(int?id)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Categoria alumno = db.Categoria.Find(id);
                 db.Entry(alumno).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Exemplo n.º 4
0
 public static void Update(Categoria Categoria)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 db.Categoria.Attach(Categoria);
                 db.Entry(Categoria).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
 public static void Create(CuerpoFactura a)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 a.crf_dateOfCreated = DateTime.Now;
                 db.CuerpoFactura.Add(a);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
 public static void Delete(int?id)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 ProductoEnCarrito ProductoEnCarrito = db.ProductoEnCarrito.Find(id);
                 ProductoBLL.Update(ProductoEnCarrito.prd_id, (-1 * ProductoEnCarrito.pcr_cnt));
                 db.Entry(ProductoEnCarrito).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Exemplo n.º 7
0
 public static void Create(Cliente a)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 a.cln_tipo          = "Nuevo";
                 a.cln_dateOfCreated = DateTime.Now;
                 db.Cliente.Add(a);
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }
Exemplo n.º 8
0
 public static void Update(int prd_id, int cantidad)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Producto p = db.Producto.Find(prd_id);
                 p.prd_cnt -= cantidad;
                 db.Producto.Attach(p);
                 db.Entry(p).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception ex)
             {
                 transaction.Rollback();
                 throw ex;
             }
         }
     }
 }