public async Task<IHttpActionResult> PutVillage(int id, Village village) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != village.Id) { return BadRequest(); } db.Entry(village).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VillageExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostVillage(Village village) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Villages.Add(village); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = village.Id }, village); }