コード例 #1
0
        public bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            bool result = false;

            if (throwOnPopulatedRole == false)
            {
                List <User> allUsers = _membershipProviderApplicationService.GetAllUsersToList();

                foreach (User u in allUsers)
                {
                    if (IsUserInRole(u.UserName, roleName))
                    {
                        result = false;
                        break;
                    }
                }
            }
            else
            {
                try
                {
                    Role role = _roleRepository.FindOne(r => r.RoleName == roleName);
                    _roleRepository.Delete(role);
                    _roleRepository.Persist();
                    result = true;
                }
                catch
                {
                    result = false;
                }
            }

            return(result);
        }
コード例 #2
0
        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
        {
            char[]        charsToTrim = { '%' };
            List <User>   userList    = _membershipProviderApplicationService.GetAllUsersToList();
            List <string> uirList     = new List <string>();

            foreach (User u in userList)
            {
                if (u.UserName.StartsWith(usernameToMatch.TrimEnd(charsToTrim)))
                {
                    if (_roleProviderApplicationService.IsUserInRole(u.UserName, roleName))
                    {
                        uirList.Add(u.UserName);
                    }
                }
            }
            return(uirList.ToArray());
        }
コード例 #3
0
        //
        // GET: /User/

        public ActionResult Index()
        {
            var users = _membershipProviderApplicationService.GetAllUsersToList();

            return(View(users));
        }