public IHttpActionResult Putcity(decimal id, city city) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != city.City_id) { 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); try { db.SaveChanges(); } catch (DbUpdateException) { if (cityExists(city.City_id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = city.City_id }, city); }