public async Task<Customer> UpdateCustomer(Customer customer) { _dbContext.ApplyChanges(customer); try { await _dbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException updateEx) { throw new FaultException(updateEx.Message); } await _dbContext.LoadRelatedEntitiesAsync(customer); customer.AcceptChanges(); return customer; }
public async Task<Customer> CreateCustomer(Customer customer) { customer.TrackingState = TrackingState.Added; _dbContext.ApplyChanges(customer); try { await _dbContext.SaveChangesAsync(); } catch (DbUpdateException updateEx) { throw new FaultException(updateEx.Message); } await _dbContext.LoadRelatedEntitiesAsync(customer); customer.AcceptChanges(); return customer; }