public async Task <FileData> HandleAsync(GenerateNotificationPreviewDocument query) { var docxBytes = await notificationDocumentGenerator.GenerateNotificationDocument(query.NotificationId); var fileName = string.Format("IWS-Notification-Preview-{0}-{1}", query.NotificationId, SystemTime.UtcNow); if (pdfGenerator == null) { var wordBytes = notificationPreviewWatermarkGenerator.GenerateNotificationPreviewWatermark(docxBytes); return(new FileData(fileName, FileType.Docx, wordBytes)); } var pdfBytes = pdfGenerator.ConvertToPreviewPdf(docxBytes); return(new FileData(fileName, FileType.Pdf, pdfBytes)); }