public async Task<IHttpActionResult> PutRace(int id, Race race) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != race.Id) { return BadRequest(); } db.Entry(race).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RaceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostRace(Race race) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Races.Add(race); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = race.Id }, race); }