Ejemplo n.º 1
0
 public void UpdateCustAccount(CustomerModel CUST)
 {
     using (CustomersDBEntities db = new CustomersDBEntities())
     {
         using (var dbContextTransaction = db.Database.BeginTransaction())
         {
             try
             {
                 customer c = db.customers.Find(CUST.customerNumber);
                 c.email        = CUST.email;
                 c.address      = CUST.address;
                 c.city         = CUST.city;
                 c.state        = CUST.state;
                 c.country      = CUST.country;
                 c.postalCode   = CUST.postalCode;
                 c.customerName = CUST.customerName;
                 db.SaveChanges();
                 dbContextTransaction.Commit();
             }
             catch
             {
                 dbContextTransaction.Rollback();
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void AddCustomer(CustomerModel Cust)
 {
     using (CustomersDBEntities db = new CustomersDBEntities())
     {
         customer c = new customer();
         c.customerName = Cust.customerName;
         c.address      = Cust.address;
         c.city         = Cust.city;
         c.email        = Cust.email;
         c.state        = Cust.state;
         c.country      = Cust.country;
         c.postalCode   = Cust.postalCode;
         db.customers.Add(c);
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
        public void DeleteCustomer(int CustNo)
        {
            using (CustomersDBEntities db = new CustomersDBEntities())
            {
                using (var dbContextTransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        var SUR = db.customers.Where(o => o.customerNumber == CustNo);
                        if (SUR.Any())
                        {
                            db.customers.Remove(SUR.FirstOrDefault());
                            db.SaveChanges();
                        }

                        dbContextTransaction.Commit();
                    }
                    catch
                    {
                        dbContextTransaction.Rollback();
                    }
                }
            }
        }