public IHttpActionResult PutMenuModel(int id, MenuModel menuModel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != menuModel.id) { return BadRequest(); } db.Entry(menuModel).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MenuModelExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostMenuModel(MenuModel menuModel) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.MenuModels.Add(menuModel); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = menuModel.id }, menuModel); }