public IHttpActionResult PutRubro(int id, Rubro rubro) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != rubro.Id) { return BadRequest(); } db.Entry(rubro).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RubroExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostRubro(Rubro rubro) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Rubros.Add(rubro); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = rubro.Id }, rubro); }