public IHttpActionResult Update(int id, Aluno aluno) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != aluno.Id) { return BadRequest(); } svc.Alunos.Update(aluno); try { svc.Alunos.save(); } catch (DbUpdateConcurrencyException) { if (!AlunoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult Add(Aluno aluno) { if (!ModelState.IsValid) { return BadRequest(ModelState); } svc.Alunos.Add(aluno); svc.Alunos.save(); return CreatedAtRoute("DefaultApi", new { id = aluno.Id }, aluno); }