public async Task<IHttpActionResult> PutSchool(int id, School school) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != school.Id) { return BadRequest(); } db.Entry(school).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SchoolExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostSchool(School school) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Schools.Add(school); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = school.Id }, school); }