public async Task <IApprenticeship> GetApprenticeshipById(Guid id) { if (id == Guid.Empty) { throw new ArgumentException($"Cannot be an empty {nameof(Guid)}", nameof(id)); } Apprenticeship persisted = null; var client = _cosmosDbHelper.GetClient(); await _cosmosDbHelper.CreateDatabaseIfNotExistsAsync(client); await _cosmosDbHelper.CreateDocumentCollectionIfNotExistsAsync(client, _settings.ApprenticeshipCollectionId); var doc = _cosmosDbHelper.GetDocumentById(client, _settings.ApprenticeshipCollectionId, id); persisted = _cosmosDbHelper.DocumentTo <Apprenticeship>(doc); return(persisted); }
public async Task <ICourse> GetCourseById(Guid id) { if (id == Guid.Empty) { throw new ArgumentException($"Cannot be an empty {nameof(Guid)}", nameof(id)); } Course persisted = null; using (var client = _cosmosDbHelper.GetClient()) { var doc = _cosmosDbHelper.GetDocumentById(client, _settings.CoursesCollectionId, id); persisted = _cosmosDbHelper.DocumentTo <Course>(doc); } return(persisted); }