public static bool Updates(ProductoEnCarrito pc)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 ProductoEnCarrito prd = new ProductoEnCarrito();
                 var order             = db.ProductoEnCarrito.AsNoTracking().Where(s => s.pcr_id == pc.pcr_id).FirstOrDefault();
                 prd.pcr_id = order.pcr_id;
                 prd.prd_id = pc.prd_id;
                 prd.car_id = pc.car_id;
                 //Restablecer cantidad productos
                 var cantidad = order.pcr_cnt - pc.pcr_cnt;
                 prd.pcr_cnt            = pc.pcr_cnt;
                 order.Producto.prd_cnt = order.Producto.prd_cnt + cantidad;
                 //-----------------------
                 prd.pcr_est           = pc.pcr_est;
                 prd.pcr_dateOfCreated = order.pcr_dateOfCreated;
                 ProductoBLL.Updates(order.Producto);
                 // prd.Producto = order.Producto;
                 db.Entry(prd).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
                 return(true);
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }
예제 #2
0
 public static bool Updates(Categoria p)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Categoria cat   = new Categoria();
                 var       order = db.Categoria.AsNoTracking().Where(s => s.cat_id == p.cat_id).FirstOrDefault();
                 cat.cat_id          = order.cat_id;
                 cat.cat_nom         = p.cat_nom;
                 db.Entry(cat).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
                 return(true);
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }
예제 #3
0
        public static bool Updates(Pago p)
        {
            using (PortBellyDBEntities db = new PortBellyDBEntities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        Pago pgo   = new Pago();
                        var  order = db.Pago.AsNoTracking().Where(s => s.pgo_id == p.pgo_id).FirstOrDefault();
                        pgo.pgo_id   = order.pgo_id;
                        pgo.pgo_nom  = p.pgo_nom;
                        pgo.pgo_cseg = p.pgo_cseg;
                        pgo.pgo_fven = p.pgo_fven;
                        pgo.pgo_ntg  = p.pgo_ntg;

                        db.Entry(pgo).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        transaction.Commit();
                        return(true);
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        return(false);
                    }
                }
            }
        }
예제 #4
0
 public static bool Updates(Producto p)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Producto prd   = new Producto();
                 var      order = db.Producto.AsNoTracking().Where(s => s.prd_id == p.prd_id).FirstOrDefault();
                 prd.prd_id            = order.prd_id;
                 prd.prd_nom           = p.prd_nom;
                 prd.prd_crt           = p.prd_crt;
                 prd.prd_img           = p.prd_img;
                 prd.prd_prc           = p.prd_prc;
                 prd.prd_tal           = p.prd_tal;
                 prd.cat_id            = p.cat_id;
                 prd.prm_id            = p.prm_id;
                 prd.prd_dateOfCreated = order.prd_dateOfCreated;
                 prd.prd_cnt           = p.prd_cnt;
                 db.Entry(prd).State   = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
                 return(true);
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }
예제 #5
0
 public static bool Updates(Promocion p)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Promocion prm   = new Promocion();
                 var       order = db.Promocion.AsNoTracking().Where(s => s.prm_id == p.prm_id).FirstOrDefault();
                 prm.prm_id          = order.prm_id;
                 prm.prm_nom         = p.prm_nom;
                 prm.prm_tip         = p.prm_tip;
                 prm.prm_can         = p.prm_can;
                 prm.prm_por         = p.prm_por;
                 db.Entry(prm).State = System.Data.Entity.EntityState.Modified;
                 db.SaveChanges();
                 transaction.Commit();
                 return(true);
             }
             catch (Exception)
             {
                 transaction.Rollback();
                 return(false);
             }
         }
     }
 }
예제 #6
0
 public static void Delete(int?id)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 Usuario alumno = db.Usuario.Find(id);
                 db.Entry(alumno).State = System.Data.Entity.EntityState.Deleted;
                 db.SaveChanges();
                 transaction.Commit();
             }
             catch (Exception)
             {
                 transaction.Rollback();
             }
         }
     }
 }
예제 #7
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();
             }
         }
     }
 }
예제 #8
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 Delete(int?id)
 {
     using (PortBellyDBEntities db = new PortBellyDBEntities())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             try
             {
                 CuerpoFactura CuerpoFactura = db.CuerpoFactura.Find(id);
                 db.Entry(CuerpoFactura).State = System.Data.Entity.EntityState.Deleted;
                 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;
             }
         }
     }
 }
예제 #11
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;
             }
         }
     }
 }