public IHttpActionResult PutRol(int id, Rol rol) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != rol.RolID) { return BadRequest(); } db.Entry(rol).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RolExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostRol(Rol rol) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Rols.Add(rol); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = rol.RolID }, rol); }