Example #1
0
        public Role GetRoleByRoleId(int roleId)
        {
            Role   role     = new Role();
            string roleName = this.manager.GetRoleName(roleId);

            role.RoleId = roleId;
            if (roleName != null)
            {
                role.RoleName = roleName;
            }
            IList <int> permissionIds = manager.GetPermissionIdsByRoleId(roleId);

            foreach (int id in permissionIds)
            {
                Permission permission = Permissions.GetPermissionById(id);
                if (permission != Permissions.Null)
                {
                    role.Permissions.AddPermission(permission);
                }
            }
            if (roleId == RoleIds.AllPermissionId)
            {
                role.DefaultRole = true;
            }
            return(role);
        }