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); }