public IHttpActionResult PostCustomer(Customer customer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _customerService.AddCustomer(customer); return CreatedAtRoute("DefaultApi", new { id = customer.ID }, customer); }
// PUT api/Customer/5 /// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="customer"></param> /// <returns></returns> public IHttpActionResult PutCustomer(int id, Customer customer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != customer.ID) { return BadRequest(); } _customerService.UpdateCustomer(customer); return StatusCode(HttpStatusCode.NoContent); }