public async Task<IHttpActionResult> PostRecipeProcess(RecipeProcess recipeProcess) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.RecipeProcesses.Add(recipeProcess); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (RecipeProcessExists(recipeProcess.RecipeId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = recipeProcess.RecipeId }, recipeProcess); }
public async Task<IHttpActionResult> PutRecipeProcess(int id, RecipeProcess recipeProcess) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != recipeProcess.RecipeId) { return BadRequest(); } db.Entry(recipeProcess).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecipeProcessExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }