public IHttpActionResult CreateRolesForUser([FromBody] RolesToUser model) { objInj = objInj ?? new AspNetUserRolesService(); var currentAreas = objInj.GetAll(c => c.UserId == model.id, null, includes: c => c.AspNetRoles); var denoms = new List <int>(currentAreas.Select(c => c.IDAspNetUserRol)); objInj.CreateAndRemove(model.EnrolledRoles, denoms); return(Ok()); }
public async Task <IHttpActionResult> SoftDeleteRole(string Id) { var role = await RoleManager.FindByIdAsync(Id); if (role != null) { ApplicationRole rol = ((ApplicationRole)role); rol.Estatus = 0; IdentityResult result = await RoleManager.UpdateAsync(rol); if (result.Succeeded) { var currentRoles = objInj.GetAll(c => c.RoleId == Id, null, includes: c => c.AspNetRoles); var denoms = new List <int>(currentRoles.Select(c => c.IDAspNetUserRol)); objInj.CreateAndRemove(null, denoms); } else { return(InternalServerError()); } return(Ok()); } return(NotFound()); }