public IHttpActionResult PutDetalheEvento(int id, DetalheEvento detalheEvento) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != detalheEvento.IdDetalheEvento) { return BadRequest(); } db.Entry(detalheEvento).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DetalheEventoExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostDetalheEvento(DetalheEvento detalheEvento) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.DetalheEvento.Add(detalheEvento); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = detalheEvento.IdDetalheEvento }, detalheEvento); }