public IHttpActionResult PutBeverage(int id, Beverage beverage) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != beverage.ID) { return BadRequest(); } db.Entry(beverage).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BeverageExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostBeverage(Beverage beverage) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Beverages.Add(beverage); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = beverage.ID }, beverage); }