public Customer AddCustomer(Customer customer) { using (var entities = new HillStationEntities()) { entities.Customers.Add(customer); entities.SaveChanges(); entities.Entry(customer).Reload(); return(customer); } }
private void Save() { using (var entities = new HillStationEntities()) { foreach (var header in Headers) { entities.Headers.Attach(header); entities.Entry(header).State = EntityState.Modified; foreach (var meal in header.Meals) { entities.Meals.Attach(meal); entities.Entry(meal).State = EntityState.Modified; } } entities.SaveChanges(); OnMenuOpdated(new MenuUpdatedEventArgs { UpdateOperation = UpdateOperation.Updated }); } }