public IHttpActionResult PutSubMenu(int id, SubMenu subMenu) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != subMenu.Id) { return BadRequest(); } db.Entry(subMenu).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SubMenuExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostSubMenu(SubMenu subMenu) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.SubMenus.Add(subMenu); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = subMenu.Id }, subMenu); }