public IHttpActionResult PutScore(int id, Score score) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != score.Id) { return BadRequest(); } db.Entry(score).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ScoreExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostScore(Score score) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Scores.Add(score); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = score.Id }, score); }