public async Task <IEnumerable <IStandardsAndFrameworks> > StandardsAndFrameworksSearch(string search) { Throw.IfNullOrWhiteSpace(search, nameof(search)); IEnumerable <IStandardsAndFrameworks> persisted = null; var client = _cosmosDbHelper.GetClient(); await _cosmosDbHelper.CreateDatabaseIfNotExistsAsync(client); await _cosmosDbHelper.CreateDocumentCollectionIfNotExistsAsync(client, _settings.StandardsCollectionId); await _cosmosDbHelper.CreateDocumentCollectionIfNotExistsAsync(client, _settings.FrameworksCollectionId); var standardDocs = _cosmosDbHelper.GetStandardsAndFrameworksBySearch(client, _settings.StandardsCollectionId, search); var frameworkDocs = _cosmosDbHelper.GetStandardsAndFrameworksBySearch(client, _settings.FrameworksCollectionId, search); if (frameworkDocs.Count > 0) { frameworkDocs = _cosmosDbHelper.GetProgTypesForFramework(client, _settings.ProgTypesCollectionId, frameworkDocs); } var apprenticeshipsForUKPRN = persisted = standardDocs.Concat(frameworkDocs); return(persisted); }