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