public IHttpActionResult PostOrder_Status(Order_Status order_status) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Order_Status.Add(order_status); try { db.SaveChanges(); } catch (DbUpdateException) { if (Order_StatusExists(order_status.ID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = order_status.ID }, order_status); }
// PUT api/Demo/5 public IHttpActionResult PutOrder_Status(int id, Order_Status order_status) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != order_status.ID) { return BadRequest(); } db.Entry(order_status).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!Order_StatusExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }