public IHttpActionResult PostAula(Aula aula) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Aula.Add(aula); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = aula.IdAula }, aula); }
public IHttpActionResult PutAula(int id, Aula aula) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != aula.IdAula) { return BadRequest(); } db.Entry(aula).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AulaExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }