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