public async Task<IHttpActionResult> PutPrimeMinister(int id, PrimeMinister primeMinister) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != primeMinister.Id) { return BadRequest(); } db.Entry(primeMinister).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrimeMinisterExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostPrimeMinister(PrimeMinister primeMinister) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.PrimeMinisters.Add(primeMinister); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = primeMinister.Id }, primeMinister); }