public IHttpActionResult PostRace(Race race) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Races.Add(race); try { db.SaveChanges(); } catch (DbUpdateException) { if (RaceExists(race.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = race.Id }, race); }
public IHttpActionResult PutRace(Guid id, Race race) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != race.Id) { return BadRequest(); } db.Entry(race).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RaceExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }