public async Task<IHttpActionResult> PostRecipeCategories(RecipeCategories recipeCategories) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.RecipeCategories.Add(recipeCategories); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (RecipeCategoriesExists(recipeCategories.RecipeID)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = recipeCategories.RecipeID }, recipeCategories); }
public async Task<IHttpActionResult> PutRecipeCategories(int id, RecipeCategories recipeCategories) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != recipeCategories.RecipeID) { return BadRequest(); } db.Entry(recipeCategories).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeCategoriesExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }