public List <UserRolesInfo> FilterUsers(UserSearchQueryModel query, UserManager <ApplicationUser> userManager) { var role = db.Roles.FirstOrDefault(r => r.Name == query.Role); return(db.Users .FilterByName(query.NamePrefix) .FilterByRole(role, userManager) .FilterByUserIds( userRolesRepo.GetListOfUsersWithCourseRole(query.CourseRole, query.CourseId), userRolesRepo.GetListOfUsersByPrivilege(query.OnlyPrivileged, query.CourseId) ) .GetUserRolesInfo(50, userManager)); }
public List <UserRolesInfo> FilterUsers(UserSearchQueryModel query, UserManager <ApplicationUser> userManager, int limit = 50) { var role = db.Roles.FirstOrDefault(r => r.Name == query.Role); IQueryable <ApplicationUser> users = db.Users; if (!string.IsNullOrEmpty(query.NamePrefix)) { var usersIds = GetUsersByNamePrefix(query.NamePrefix).Select(u => u.Id); users = users.Where(u => usersIds.Contains(u.Id)); } return(users .FilterByRole(role, userManager) .FilterByUserIds( userRolesRepo.GetListOfUsersWithCourseRole(query.CourseRole, query.CourseId), userRolesRepo.GetListOfUsersByPrivilege(query.OnlyPrivileged, query.CourseId) ) .GetUserRolesInfo(limit, userManager)); }