public Customer GetCustomer(int id) { Customer customer = new Customer(); customer.Id = id; customer = new entityServices.CustomerService().Load(customer); return customer; }
public void UpdateCustomer(Customer customer) { Guid dataSignature = DataSignature.Current; if (dataSignature == Guid.Empty) { //this is an update method, so no data signature to //compare against is an exception: throw new FaultException<NoDataSignature>(new NoDataSignature()); } Customer currentState = CustomerEntityService.Load(customer); Guid currentDataSignature = DataSignature.Sign(currentState); //if the data signatures match then update: if (currentDataSignature == dataSignature) { CustomerEntityService.Update(customer); } else { //otherwise, throw concurrency violation exception: throw new FaultException<ConcurrencyViolation>(new ConcurrencyViolation()); } }