public void UpdateCustomerUsingDTO(CustomerDTO customer)
 {
     using (var ctx = new OrderIT.Model.OrderITEntities())
     {
         var newCustomer = new OrderIT.Model.Customer {
             CompanyId = customer.CompanyId, Version = customer.Version
         };
         ctx.Companies.Attach(newCustomer);
         newCustomer.ShippingAddress = customer.ShippingAddress;
         newCustomer.BillingAddress  = customer.BillingAddress;
         newCustomer.Name            = customer.Name;
         ctx.SaveChanges();
     }
 }
 public void DeleteCustomer(int customerId, byte[] version)
 {
     using (var ctx = new OrderIT.Model.OrderITEntities())
     {
         var customerToDelete = new OrderIT.Model.Customer
         {
             CompanyId = customerId,
             Version   = version
         };
         ctx.Companies.Attach(customerToDelete);
         ctx.Companies.DeleteObject(customerToDelete);
         ctx.SaveChanges();
     }
 }
 /*ICustomerDTOService Interface*/
 public int CreateCustomerUsingDTO(CustomerDTO customer)
 {
     using (var ctx = new OrderIT.Model.OrderITEntities())
     {
         var customerToAdd = new OrderIT.Model.Customer
         {
             BillingAddress  = customer.BillingAddress,
             Name            = customer.Name,
             ShippingAddress = customer.ShippingAddress,
             WSEnabled       = false
         };
         ctx.Companies.AddObject(customerToAdd);
         ctx.SaveChanges();
         return(customerToAdd.CompanyId);
     }
 }
 public void DeleteCustomerUsingDTO(int customerId, byte[] version)
 {
     using (var ctx = new OrderIT.Model.OrderITEntities())
     {
         var customerToDelete = new OrderIT.Model.Customer
         {
             CompanyId       = customerId,
             Version         = version,
             ShippingAddress = new Model.AddressInfo(),
             BillingAddress  = new Model.AddressInfo()
         };
         ctx.Companies.Attach(customerToDelete);
         ctx.Companies.DeleteObject(customerToDelete);
         ctx.SaveChanges();
     }
 }