public async Task<IHttpActionResult> PutOrderStatus(int id, OrderStatus orderStatus) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != orderStatus.Id) { return BadRequest(); } db.Entry(orderStatus).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderStatusExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostOrderStatus(OrderStatus orderStatus) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.OrderStatus.Add(orderStatus); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = orderStatus.Id }, orderStatus); }