public RoleAssociation <FolderDefinition> WithRole(string roleName) { var association = new RoleAssociation <FolderDefinition>(this, roleName); roleAssociations.Add(association); return(association); }
public async Task <AssociateRolesViewModel> GetUserRoles(int userId) { var result = new AssociateRolesViewModel(); var userRoles = await _unitOfWork.Roles.GetUserRolesAsync(userId); var allRoles = await _unitOfWork.Roles.GetAllAsync(); var user = await _unitOfWork.Users.FindAsync(userId); result.UserName = user.UserName; foreach (var role in allRoles) { var roleAssociation = new RoleAssociation { RoleId = role.Id, RoleName = role.Name }; if (userRoles.Any(r => r.Id == role.Id)) { roleAssociation.IsActive = true; } result.RoleAssociations.Add(roleAssociation); } return(result); }