public void CreateCustomer(Customer customer) { using (var db = new OskarEntities()) { db.Customers.Add(customer); db.SaveChanges(); } }
public void UpdateCustomer(Customer customer) { using (var db = new OskarEntities()) { db.Customers.Attach(customer); db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); } }
public void DeleteCustomer(int customerId) { using (var db = new OskarEntities()) { var customer = new Customer { CustomerId = customerId }; db.Customers.Attach(customer); db.Customers.Remove(customer); db.SaveChanges(); } }