public IHttpActionResult PutObservacao(int id, Observacao observacao) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != observacao.Id) { return BadRequest(); } db.Entry(observacao).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ObservacaoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostObservacao(Observacao observacao) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Observacaos.Add(observacao); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = observacao.Id }, observacao); }