public static CustomerModel GetCustomer(Customer c)
 {
     return new CustomerModel()
     {
         CustomerID = c.CustomerID,
         Address = c.Address,
         City = c.City,
         CompanyName = c.CompanyName,
         ContactName = c.ContactName,
         ContactTitle = c.ContactTitle,
         Country = c.Country,
         Fax = c.Fax,
         Phone = c.Phone,
         PostalCode = c.PostalCode
     };
 }
 public IHttpActionResult CreateCustomer(CustomerModel newCustomer)
 {
     var entity = new Customer()
     {
         Address = newCustomer.Address,
         City = newCustomer.City,
         CompanyName = newCustomer.CompanyName,
         ContactName = newCustomer.ContactName,
         ContactTitle = newCustomer.ContactTitle,
         Country = newCustomer.Country,
         Fax = newCustomer.Fax,
         Phone = newCustomer.Phone,
         PostalCode = newCustomer.PostalCode,
         Region = newCustomer.Region
     };
     _repository.CreateCustomer(entity);
     var loc = Url.Link("api/customers/{customerID}", new { customerID = newCustomer.CustomerID});
     return Created<CustomerModel>(loc, newCustomer);
 }
 public void CreateCustomer(Customer newCustomer)
 {
     _dbContext.Customers.Add(newCustomer);
     _dbContext.SaveChanges();
 }
 public IHttpActionResult UpdateCustomer(CustomerModel customerToUpdate)
 {
     var entity = new Customer()
     {
         CustomerID = customerToUpdate.CustomerID,
         Address = customerToUpdate.Address,
         City = customerToUpdate.City,
         CompanyName = customerToUpdate.CompanyName,
         ContactName = customerToUpdate.ContactName,
         ContactTitle = customerToUpdate.ContactTitle,
         Country = customerToUpdate.Country,
         Fax = customerToUpdate.Fax,
         Phone = customerToUpdate.Phone,
         PostalCode = customerToUpdate.PostalCode,
         Region = customerToUpdate.Region
     };
     _repository.UpdateCustomer(entity);
     return Ok<CustomerModel>(customerToUpdate);
 }
 public void UpdateCustomer(Customer customerToUpdate)
 {
     _dbContext.Customers.Attach(customerToUpdate);
     _dbContext.Entry<Customer>(customerToUpdate).State = EntityState.Modified;
     _dbContext.SaveChanges();
 }