コード例 #1
0
        private async Task <DocumentAssetFile> GetDocumentAssetFile(int assetId)
        {
            DocumentAssetFile file = null;

            try
            {
                var query = new GetDocumentAssetFileByIdQuery(assetId);
                file = await _queryExecutor.ExecuteAsync(query);
            }
            catch (FileNotFoundException ex)
            {
                // If the file exists but the file has gone missing, log and return a 404
                _logger.LogError(0, ex, "Document Asset exists, but has no file: {0}", assetId);
            }

            return(file);
        }
コード例 #2
0
        public async Task <ActionResult> File(int assetId, string fileName, string extension)
        {
            DocumentAssetFile file = null;

            try
            {
                var query = new GetDocumentAssetFileByIdQuery(assetId);
                file = await _queryExecutor.ExecuteAsync(query);
            }
            catch (FileNotFoundException ex)
            {
                // If the file exists but the file has gone missing, log and return a 404
                _logger.LogError(0, ex, "Document Asset exists, but has no file: {0}", assetId);
            }

            if (file == null)
            {
                return(FileAssetNotFound("File not found"));
            }

            return(File(file.ContentStream, file.ContentType, file.FileName));
        }
コード例 #3
0
        public IDomainRepositoryQueryContext <DocumentAssetFile> AsFile()
        {
            var query = new GetDocumentAssetFileByIdQuery(_documentAssetId);

            return(DomainRepositoryQueryContextFactory.Create(query, ExtendableContentRepository));
        }