public IHttpActionResult PutRol(int id, Rol rol) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != rol.Id) { 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 Put(int id, [FromBody] Usuario value) { if (ModelState.IsValid) { var UsuarioExiste = db.Usuarios.Count(c => c.Id == id) > 0; if (UsuarioExiste) { db.Entry(value).State = EntityState.Modified; db.SaveChanges(); return(Ok()); } else { return(NotFound()); } } else { return(BadRequest()); } }