public async Task <Analysis> GetAsync(string platformId, string analysisId) { var response = await AnalysesContainer.ReadItemAsync <Analysis>(analysisId, new PartitionKey(platformId)); if (response?.Resource == null) { throw new ArgumentException($"No analysis could be retrieved for Platform: {platformId} and AnalysisId: {analysisId}. Status: {response.StatusCode}"); } return(response.Resource); }
public async Task SaveAsync(Analysis analysis) { var analysisResponse = await AnalysesContainer.CreateItemAsync(analysis, new PartitionKey(analysis.PlatformId)); if (!IsSuccessful(analysisResponse.StatusCode)) { throw new Exception($"Analysis for Platform: {analysis.PlatformId}, AnalysisId: {analysis.Id} could not be saved"); } var platformResponse = await PlatformsContainer.UpsertItemAsync( new PlatformSummary { Id = analysis.PlatformId, AnalysisId = analysis.Id }, new PartitionKey(analysis.PlatformId) ); if (!IsSuccessful(platformResponse.StatusCode)) { throw new Exception($"Platform-Analysis (PlatformId: {analysis.PlatformId}, AnalysisId: {analysis.Id}) mapping configuration could not be saved"); } }