public void SaveUpdatedCustomer(Customer cust) { using (var context = new CustomerContext()) { context.Entry(cust).State = EntityState.Modified; context.SaveChanges(); } }
public void DeleteCustomer(int id) { using (var context = new CustomerContext()) { var cust = context.Customers .Find (id); context.Entry(cust).State = EntityState.Deleted; context.SaveChanges(); } }
public void SaveUpdatedOrder(Order order, int custId) { using (var context = new CustomerContext()) { var orderFromDb = context.Orders.Include(n => n.Customer).FirstOrDefault(o => o.Id == order.Id); context.Entry(orderFromDb).CurrentValues.SetValues(order); context.SaveChanges(); } }