public IHttpActionResult PutOrder(int id, Order order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != order.ID) { return BadRequest(); } db.Entry(order).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.OK); }
public IHttpActionResult PostOrder(Order order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Orders.Add(order); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = order.ID }, order); }