private void ExecuteCmdletWithAll()

in src/Modules/Workspaces/Commands.Workspaces/GetPowerBIWorkspace.cs [207:245]


        private void ExecuteCmdletWithAll()
        {
            using (var client = this.CreateClient())
            {
                if (this.Scope == PowerBIUserScope.Individual)
                {
                    var allWorkspacesOfUser = this.ExecuteCmdletWithAll((top, skip) => client.Workspaces.GetWorkspaces(filter: this.Filter, top: top, skip: skip));
                    this.Logger.WriteObject(allWorkspacesOfUser, true);
                    return;
                }

                var allWorkspaces = this.ExecuteCmdletWithAll((top, skip) => client.Workspaces.GetWorkspacesAsAdmin(expand: this.GetExpandClauseForWorkspace(), filter: this.Filter, top: top, skip: skip));

                var filteredWorkspaces = new List<Workspace>();

                if (!string.IsNullOrEmpty(this.User))
                {
                    allWorkspaces = allWorkspaces
                        .Where(w => w.Users != null && w.Users.Any(u => u.UserPrincipalName != null && u.UserPrincipalName.Equals(this.User, StringComparison.OrdinalIgnoreCase)))
                        .ToList();
                }

                if (this.Deleted.IsPresent)
                {
                    filteredWorkspaces.AddRange(allWorkspaces.Where(w => w.State.Equals(WorkspaceState.Deleted)));
                }
                else if (this.Orphaned.IsPresent)
                {
                    filteredWorkspaces.AddRange(allWorkspaces.Where(w => w.IsOrphaned));
                }
                else
                {
                    this.Logger.WriteObject(allWorkspaces, true);
                    return;
                }

                this.Logger.WriteObject(filteredWorkspaces, true);
            }
        }