public IHttpActionResult PutCustomer(int id, Customer customer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != customer.Id) { return BadRequest(); } try { rep.Update(id, customer); } catch (DbUpdateConcurrencyException) { if (!rep.CustomerExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCustomer(Customer customer) { if (!ModelState.IsValid) { return BadRequest(ModelState); } rep.Add(customer); return CreatedAtRoute("DefaultApi", new { id = customer.Id }, customer); }