コード例 #1
0
ファイル: GKNMDBContext.cs プロジェクト: meothailand/GKNMShop
 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
ファイル: GKNMDBContext.cs プロジェクト: meothailand/GKNMShop
 public int CreateCustomer(Customer customer)
 {
     using (var context = new GiaikhatNgocMaiEntities())
     {
         context.Customers.Add(customer);
         context.SaveChanges();
         return customer.Id;
     }
 }