public IHttpActionResult PutTecnologia(int id, Tecnologia tecnologia) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != tecnologia.Id) { return BadRequest(); } db.Entry(tecnologia).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TecnologiaExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostTecnologia(Tecnologia tecnologia) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (tecnologia.Id > 0 && TecnologiaExists(tecnologia.Id)) return PutTecnologia(tecnologia.Id, tecnologia); db.Tecnologias.Add(tecnologia); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = tecnologia.Id }, tecnologia); }