public async Task<IHttpActionResult> PutDishCategory(int id, DishCategory dishCategory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != dishCategory.ID) { return BadRequest(); } db.Entry(dishCategory).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DishCategoryExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostDishCategory(DishCategory dishCategory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.DishCategories.Add(dishCategory); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = dishCategory.ID }, dishCategory); }