public 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 { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!CountryExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostCountry(Country country) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Countries.Add(country); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = country.ID }, country); }