public IHttpActionResult CreateCustomer(CustomerDTo customerDto) { if (!ModelState.IsValid) { return(BadRequest()); } var customer = Mapper.Map <CustomerDTo, customer>(customerDto); _context.Customer.Add(customer); _context.SaveChanges(); customerDto.id = customer.id; return(Created(new Uri(Request.RequestUri + "/" + customer.id), customerDto)); }
public IHttpActionResult UpdateCustomer(int id, CustomerDTo customerDto) { if (!ModelState.IsValid) { return(BadRequest()); } var customerInDb = _context.Customer.SingleOrDefault(c => c.id == id); if (customerInDb == null) { return(NotFound()); } Mapper.Map(customerDto, customerInDb); _context.SaveChanges(); return(Ok()); }