public IHttpActionResult PostOrder(Order order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } _orderService.AddOrder(order); return CreatedAtRoute("DefaultApi", new { id = order.ID }, order); }
// PUT api/Order/5 public IHttpActionResult PutOrder(int id, Order order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != order.ID) { return BadRequest(); } _orderService.UpdateOrder(order); return StatusCode(HttpStatusCode.NoContent); }