// PUT odata/Weather(5) public async Task<IHttpActionResult> Put([FromODataUri] int key, Weather weather) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (key != weather.WeatherId) { return BadRequest(); } db.Entry(weather).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WeatherExists(key)) { return NotFound(); } else { throw; } } return Updated(weather); }
// POST odata/Weather public async Task<IHttpActionResult> Post(Weather weather) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Weathers.Add(weather); await db.SaveChangesAsync(); return Created(weather); }