public IHttpActionResult PutCrisis(int id, Crisis crisis) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != crisis.CrisisId) { return BadRequest(); } db.Entry(crisis).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CrisisExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCrisis(Crisis crisis) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Crises.Add(crisis); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = crisis.CrisisId }, crisis); }