public IHttpActionResult PutCitiesHavePopulation(int id, CitiesHavePopulation citiesHavePopulation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != citiesHavePopulation.PUID) { return(BadRequest()); } db.Entry(citiesHavePopulation).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CitiesHavePopulationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetCitiesHavePopulation(int id) { CitiesHavePopulation citiesHavePopulation = db.CitiesHavePopulations.Find(id); if (citiesHavePopulation == null) { return(NotFound()); } return(Ok(citiesHavePopulation)); }
public IHttpActionResult PostCitiesHavePopulation(CitiesHavePopulation citiesHavePopulation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CitiesHavePopulations.Add(citiesHavePopulation); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = citiesHavePopulation.PUID }, citiesHavePopulation)); }
public IHttpActionResult DeleteCitiesHavePopulation(int id) { CitiesHavePopulation citiesHavePopulation = db.CitiesHavePopulations.Find(id); if (citiesHavePopulation == null) { return(NotFound()); } db.CitiesHavePopulations.Remove(citiesHavePopulation); db.SaveChanges(); return(Ok(citiesHavePopulation)); }