public IHttpActionResult PostSeance(Seance seance) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Seances.Add(seance); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = seance.SeanceId }, seance); }
public IHttpActionResult PutSeance(int id, Seance seance) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != seance.SeanceId) { return BadRequest(); } db.Entry(seance).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SeanceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }