Files
DXApp/DXApp.TemplateKitProject/Program.cs
2026-06-09 11:49:03 +02:00

42 lines
1.4 KiB
C#

using DXApp.TemplateKitProject.Data;
using DXApp.TemplateKitProject.Services;
using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
// Datenbank
var connectionString = builder.Configuration.GetConnectionString("EcmContext")
?? throw new InvalidOperationException("Connection string 'EcmContext' not found.");
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlServer(connectionString));
// Services
builder.Services.AddScoped<PdfAttachmentExtractorService>();
builder.Services.AddScoped<PdfResultPackageService>();
builder.Services.AddScoped<ZugferdExtractorService>();
builder.Services.AddScoped<ZugferdParserService>();
builder.Services.AddScoped<ZugferdImportService>();
builder.Services.AddScoped<AttachmentViewerService>();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
// MIME-Types für PDF.js registrieren (einmaliger UseStaticFiles-Aufruf)
var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
provider.Mappings[".mjs"] = "text/javascript";
provider.Mappings[".ftl"] = "text/plain";
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();