public IHttpActionResult PutWeatherModel(int id, RawWeatherData weatherData) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != weatherData.No) { return(BadRequest()); } db.Entry(weatherData).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!WeatherModelExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostWeatherModel(RawWeatherData weatherData) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var weatherModel = new WeatherModel(weatherData); db.WeatherModels.Add(weatherModel); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = weatherModel.WeatherModelId }, weatherModel)); }