Exemple #1
0
        // -- Snip --

        public override string[] GetAllRoles()
        {
            using (var usersContext = new UserRepository())
            {
                // return usersContext.Roles.Select(r => r.RoleName).ToArray();
                return usersContext.GetAllRoles();
            }
        }
Exemple #2
0
        // -- Snip --

        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
        {
            var usersContext = new UserRepository();
            foreach (string username in usernames)
            {
                UserDetails userDetails = usersContext.GetUserByName(username);
                foreach (string role in roleNames)
                {
                    if (usersContext.GetAllRoles().Contains(role))
                        userDetails.UserRoles.Add(role);

                }
            }
        }