Пример #1
0
 public void UpdateCustomer(Customer customer)
 {
     using (var context = new GiaikhatNgocMaiEntities())
     {
         var dbcustomer = context.Customers.SingleOrDefault(i => i.Id == customer.Id);
         if (dbcustomer == null) throw new NullReferenceException();
         dbcustomer.RecieveInfo = customer.RecieveInfo;
         dbcustomer.CustomerName = customer.CustomerName;
         dbcustomer.CustomerPassword = customer.CustomerPassword;
         dbcustomer.CustomerPoint = customer.CustomerPoint;
         dbcustomer.CustomerPhone = customer.CustomerPhone;
         dbcustomer.ShipAddress = customer.ShipAddress;
         dbcustomer.ShipDistrict = customer.ShipDistrict;
         context.Entry(dbcustomer).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Пример #2
0
 public int CreateCustomer(Customer customer)
 {
     using (var context = new GiaikhatNgocMaiEntities())
     {
         context.Customers.Add(customer);
         context.SaveChanges();
         return customer.Id;
     }
 }