public IHttpActionResult PutWagon(int id, Wagon wagon) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != wagon.id) { return BadRequest(); } db.Entry(wagon).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!WagonExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostWagon(Wagon wagon) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.wagons.Add(wagon); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = wagon.id }, wagon); }