// PUT api/Orders/5 public async Task<IHttpActionResult> PutOrder(int id, Order order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != order.OrderID) { return BadRequest(); } db.Entry(order).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostOrder(Order order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Orders.Add(order); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = order.OrderID }, order); }