using DXApp.TemplateKitProject.Models; namespace DXApp.TemplateKitProject.Services; public class AttachmentViewerService { public AttachmentViewerType DetermineViewerType(string fileName) { var extension = Path.GetExtension(fileName).ToLowerInvariant(); return extension switch { ".pdf" => AttachmentViewerType.Pdf, ".xml" => AttachmentViewerType.Xml, ".txt" => AttachmentViewerType.Text, ".jpg" or ".jpeg" or ".png" or ".gif" => AttachmentViewerType.Image, ".docx" or ".doc" => AttachmentViewerType.Word, _ => AttachmentViewerType.Download }; } public string GetMimeType(string fileName) { var extension = Path.GetExtension(fileName).ToLowerInvariant(); return extension switch { ".pdf" => "application/pdf", ".xml" => "application/xml", ".txt" => "text/plain", ".jpg" or ".jpeg" => "image/jpeg", ".png" => "image/png", ".gif" => "image/gif", ".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".doc" => "application/msword", _ => "application/octet-stream" }; } } public enum AttachmentViewerType { Pdf, // PDF.js Viewer Xml, // Syntax-highlighted XML Text, // Plain Text Image, // Tag Word, // Konvertierung zu PDF (optional) Download // Nur Download-Button }