public IHttpActionResult PutCity(int id, City city) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != city.CityId) { return BadRequest(); } db.Entry(city).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CityExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCity(City city) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Cities.Add(city); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = city.CityId }, city); }