public IHttpActionResult PutQuantityAndPrice(int id, QuantityAndPrice quantityAndPrice) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != quantityAndPrice.Id) { return BadRequest(); } db.Entry(quantityAndPrice).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!QuantityAndPriceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostQuantityAndPrice(QuantityAndPrice quantityAndPrice) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.QuantityAndPrices.Add(quantityAndPrice); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = quantityAndPrice.Id }, quantityAndPrice); }