// PUT api/Food/5 public async Task<IHttpActionResult> PutFood(int id, Food food) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != food.Id) { return BadRequest(); } db.Entry(food).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FoodExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostFood(Food food) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Foods.Add(food); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = food.Id }, food); }
public void SelectEditFood(Food food) { }
public void DeleteFood(Food food) { }