public async Task <Unit> Handle(CopyContentToWorkspaceCommand request, CancellationToken cancellationToken) { var content = await _contentRepository.GetContent(request.ContentId); if (content == null) { _logger.LogError("Content {ContentId} does not exist", request.ContentId); throw new NotFoundException($"Content {request.ContentId} does not exist"); } var contentVersion = content.GetVersion(request.VersionId); if (contentVersion == null) { _logger.LogError("Version {VersionId} for content {ContentId} does not exist", request.VersionId, request.ContentId); throw new NotFoundException($"Version {request.VersionId} for content {request.ContentId} does not exist"); } // Save new content var copiedContent = new Content(content.Name, content.ContentFormat, Repository.Workspace); var copiedContentVersion = copiedContent.AddContentVersion(request.UserId, true); await _contentRepository.MergeContent(copiedContent); var file = await _blobStorageService.DownloadFile(contentVersion.Id); await _blobStorageService.UploadFile(file, copiedContentVersion.Id); return(Unit.Value); }