public async Task<IHttpActionResult> PutPoliticalParty(int id, PoliticalParty politicalParty) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != politicalParty.Id) { return BadRequest(); } db.Entry(politicalParty).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PoliticalPartyExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostPoliticalParty(PoliticalParty politicalParty) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.PoliticalParties.Add(politicalParty); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = politicalParty.Id }, politicalParty); }