// PUT api/Menu/5 public IHttpActionResult PutMenu(int id, Menu menu) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != menu.Id) { return BadRequest(); } db.Entry(menu).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MenuExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostMenu(Menu menu) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Menus.Add(menu); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = menu.Id }, menu); }