Beispiel #1
0
        public async Task DownloadUrl_GivenDatasetId_Of_NonExistingDataset_ReturnsNoContent()
        {
            //Arrange
            string datasourceId = "123123";

            ApiResponse <DatasetDownloadModel> response = new ApiResponse <DatasetDownloadModel>(HttpStatusCode.NoContent);

            _dataClient
            .DownloadDatasetFile(datasourceId)
            .Returns(response);

            //Act
            IActionResult result = await _controller.Download(datasourceId);

            //Assert
            result
            .Should()
            .BeOfType <NotFoundResult>();
        }
        public async Task <IActionResult> Download(string datasetId, int?datasetVersion = null)
        {
            Guard.ArgumentNotNull(datasetId, nameof(datasetId));

            // DATA SOURCE NAME_VERSION number_STATUS.xl

            ApiResponse <DatasetDownloadModel> apiResponse = await _datasetApiClient.DownloadDatasetFile(datasetId, datasetVersion?.ToString());

            if (apiResponse.StatusCode == HttpStatusCode.OK && !string.IsNullOrWhiteSpace(apiResponse.Content?.Url))
            {
                return(Redirect(apiResponse.Content.Url));
            }

            return(new NotFoundResult());
        }