public IHttpActionResult PostPhase(Phase phase) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Phase.Add(phase); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = phase.id }, phase); }
public IHttpActionResult PutPhase(int id, Phase phase) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != phase.id) { return BadRequest(); } db.Entry(phase).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PhaseExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }