public async Task<IHttpActionResult> PostSalesOrderDetail(SalesOrderDetail salesOrderDetail) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.SalesOrderDetails.Add(salesOrderDetail); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (SalesOrderDetailExists(salesOrderDetail.SalesOrderID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = salesOrderDetail.SalesOrderID }, salesOrderDetail); }
public async Task<IHttpActionResult> PutSalesOrderDetail(int id, SalesOrderDetail salesOrderDetail) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != salesOrderDetail.SalesOrderID) { return BadRequest(); } db.Entry(salesOrderDetail).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalesOrderDetailExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }