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