public async Task <IEnumerable <IApprenticeship> > GetApprenticeshipByUKPRN(int UKPRN) { Throw.IfNull <int>(UKPRN, nameof(UKPRN)); Throw.IfLessThan(0, UKPRN, nameof(UKPRN)); IEnumerable <Apprenticeship> persisted = null; var client = _cosmosDbHelper.GetClient(); await _cosmosDbHelper.CreateDatabaseIfNotExistsAsync(client); await _cosmosDbHelper.CreateDocumentCollectionIfNotExistsAsync(client, _settings.ApprenticeshipCollectionId); var docs = _cosmosDbHelper.GetApprenticeshipByUKPRN(client, _settings.ApprenticeshipCollectionId, UKPRN); persisted = docs; return(persisted); }
public async Task <IEnumerable <IApprenticeship> > GetApprenticeshipsByUkprn(int ukprn) { Throw.IfNull(ukprn, nameof(ukprn)); Throw.IfLessThan(0, ukprn, nameof(ukprn)); IEnumerable <Apprenticeship> persisted; using (var client = _cosmosDbHelper.GetTcpClient()) { await _cosmosDbHelper.CreateDatabaseIfNotExistsAsync(client); await _cosmosDbHelper.CreateDocumentCollectionIfNotExistsAsync(client, _cosmosSettings.ApprenticeshipCollectionId); var docs = _cosmosDbHelper.GetApprenticeshipByUKPRN(client, _cosmosSettings.ApprenticeshipCollectionId, ukprn); persisted = docs; } return(persisted); }