public async Task<IHttpActionResult> Put([FromODataUri] string key, Order update) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (key != update.Id) { return BadRequest(); } db.Entry(update).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(key)) { return NotFound(); } else { throw; } } return Updated(update); }
public async Task<IHttpActionResult> Post(Order Order) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Orders.Add(Order); await db.SaveChangesAsync(); return Created(Order); }