// PUT api/Countries/5 public async Task<IHttpActionResult> PutCountry(int id, Country country) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != country.Id) { return BadRequest(); } db.Entry(country).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostCountry(Country country) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Countries.Add(country); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = country.Id }, country); }