Updating customer details
Let's go ahead and add some code to allow for updating customer details by following these steps:
Update
ICustomerService
to add the operation shown in the following code:[OperationContract] void Update(Customer customer);
Update
CustomerService
to implement the new operation as shown in the following code:public void Update(Customer customer) { Data.Customer customerEntity = _northwindEntities .Customers.Single( c => c.CustomerID == customer.CustomerID); customerEntity.CompanyName = customer.CompanyName; customerEntity.ContactName = customer.ContactName; customerEntity.Address = customer.Address; customerEntity.City = customer.City; customerEntity.Country = customer.Country; customerEntity.Region = customer.Region; customerEntity.PostalCode = customer.PostalCode; customerEntity.Phone = customer.Phone; _northwindEntities.SaveChanges(); }
Build and then right-click on the CustomerService...