public override async Task Initialize(SelectProjectParameter parameter) { await base.Initialize(parameter); creationEnabled = parameter.CreationEnabled; taskId = parameter.TaskId; projectId = parameter.ProjectId; workspaceId = parameter.WorkspaceId; var workspaces = await interactorFactory.GetAllWorkspaces().Execute(); projectCreationSuggestionsAreEnabled = workspaces.Any(ws => ws.IsEligibleForProjectCreation()); UseGrouping = workspaces.Count() > 1; FilterText.Subscribe(async text => { var suggestions = interactorFactory.GetProjectsAutocompleteSuggestions(text.SplitToQueryWords()).Execute().SelectMany(x => x).ToEnumerable() .Cast <ProjectSuggestion>() .Select(setSelectedProject); var collectionSections = suggestions .GroupBy(project => project.WorkspaceId) .Select(grouping => grouping.OrderBy(projectSuggestion => projectSuggestion.ProjectName)) .OrderBy(grouping => grouping.First().WorkspaceName) .Select(grouping => collectionSection(grouping, prependNoProject: string.IsNullOrEmpty(text))) .ToList(); if (creationEnabled && shouldSuggestCreation(text)) { var createEntitySuggestion = new CreateEntitySuggestion(Resources.CreateProject, text); var section = new SectionModel <string, AutocompleteSuggestion>(null, new[] { createEntitySuggestion }); collectionSections.Insert(0, section); } if (collectionSections.None()) { var workspace = await interactorFactory.GetWorkspaceById(workspaceId).Execute(); var noProjectSuggestion = ProjectSuggestion.NoProject(workspace.Id, workspace.Name); collectionSections.Add( new SectionModel <string, AutocompleteSuggestion>(null, new[] { noProjectSuggestion }) ); } suggestionsSubject.OnNext(collectionSections.ToImmutableList()); }); }