Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }