/// <inheritdoc /> public async Task <FileResponse> DownloadDocumentAsync(Guid id) { this._logger.LogDebug(nameof(this.DownloadDocumentAsync), id); var query = new DownloadDocumentQuery(id); StorageFile response = await this._mediator.Send(query); return(this._mapper.Map <FileResponse>(response)); }
/// <summary> /// Handles a request /// </summary> /// <param name="request">The request</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns>Response from the request</returns> /// <exception cref="System.ArgumentNullException">document</exception> public async Task <StorageFile> Handle(DownloadDocumentQuery request, CancellationToken cancellationToken) { this._logger.LogDebug($"Handle {nameof(DownloadDocumentQuery)}", request); try { Document document = await this._repository.GetDocumentAsync(request.Id); if (document is null) { throw new ArgumentNullException(nameof(document)); } StorageFile file = await this._storageManager.DownloadAsync(document.Id.ToString()); return(file); } catch (Exception exception) { this._logger.LogError(exception, exception.Message, request); return(null); } }