public IHttpActionResult PutStop(int id, Stop stop) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != stop.StopId) { return BadRequest(); } db.Entry(stop).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!StopExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostStop(Stop stop) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Stops.Add(stop); try { db.SaveChanges(); } catch (DbUpdateException) { if (StopExists(stop.StopId)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = stop.StopId }, stop); }