Exemple #1
0
        public IEnumerable <UserHelperModel> GetUsers()
        {
            var model = new List <UserHelperModel>();

            var localUsers = LocalUserRepository.GetAll();
            var plexUsers  = PlexUserRepository.GetAll();

            foreach (var user in localUsers)
            {
                var props = ByteConverterHelper.ReturnObject <UserProperties>(user.UserProperties);
                model.Add(new UserHelperModel
                {
                    Type         = UserType.LocalUser,
                    Username     = user.UserName,
                    UserAlias    = props.UserAlias,
                    EmailAddress = props.EmailAddress,
                    Permissions  = (Permissions)user.Permissions
                });
            }

            model.AddRange(plexUsers.Select(user => new UserHelperModel
            {
                Type         = UserType.LocalUser,
                Username     = user.Username,
                UserAlias    = user.UserAlias,
                EmailAddress = user.EmailAddress,
                Permissions  = (Permissions)user.Permissions
            }));

            return(model);
        }
Exemple #2
0
        public IEnumerable <UserHelperModel> GetUsersWithPermission(Permissions permission)
        {
            var model = new List <UserHelperModel>();

            var localUsers = LocalUserRepository.GetAll().ToList();
            var plexUsers  = PlexUserRepository.GetAll().ToList();
            var embyUsers  = EmbyUserRepository.GetAll().ToList();

            var filteredLocal = localUsers.Where(x => ((Permissions)x.Permissions).HasFlag(permission));
            var filteredPlex  = plexUsers.Where(x => ((Permissions)x.Permissions).HasFlag(permission));
            var filteredEmby  = embyUsers.Where(x => ((Permissions)x.Permissions).HasFlag(permission));


            foreach (var user in filteredLocal)
            {
                var props = ByteConverterHelper.ReturnObject <UserProperties>(user.UserProperties);
                model.Add(new UserHelperModel
                {
                    Type         = UserType.LocalUser,
                    Username     = user.UserName,
                    UserAlias    = props.UserAlias,
                    EmailAddress = props.EmailAddress,
                    Permissions  = (Permissions)user.Permissions,
                    Features     = (Features)user.Features
                });
            }

            model.AddRange(filteredPlex.Select(user => new UserHelperModel
            {
                Type         = UserType.PlexUser,
                Username     = user.Username,
                UserAlias    = user.UserAlias,
                EmailAddress = user.EmailAddress,
                Permissions  = (Permissions)user.Permissions,
                Features     = (Features)user.Features
            }));

            model.AddRange(filteredEmby.Select(user => new UserHelperModel
            {
                Type         = UserType.EmbyUser,
                Username     = user.Username,
                UserAlias    = user.UserAlias,
                EmailAddress = user.EmailAddress,
                Permissions  = (Permissions)user.Permissions,
                Features     = (Features)user.Features
            }));


            return(model);
        }