public async Task<IHttpActionResult> PutTeste(int id, Teste teste) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != teste.id) { return BadRequest(); } db.Entry(teste).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TesteExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostTeste(Teste teste) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Testes.Add(teste); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = teste.id }, teste); }