public IHttpActionResult PutOrderDetail(int id, OrderDetail orderDetail) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != orderDetail.OrderDetailId) { return BadRequest(); } db.Entry(orderDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!OrderDetailExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostOrderDetail(OrderDetail orderDetail) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.OrderDetails.Add(orderDetail); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = orderDetail.OrderDetailId }, orderDetail); }