using Microsoft.EntityFrameworkCore; using MudBlazor.Services; using TrafagSalesExporter.Data; using TrafagSalesExporter.Services; var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); builder.Services.AddMudServices(); builder.Services.AddDbContextFactory(options => options.UseSqlite("Data Source=trafag_exporter.db")); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddHostedService(); var app = builder.Build(); using (var scope = app.Services.CreateScope()) { var dbFactory = scope.ServiceProvider.GetRequiredService>(); var cryptoService = scope.ServiceProvider.GetRequiredService(); await using var db = await dbFactory.CreateDbContextAsync(); await db.Database.EnsureCreatedAsync(); await DbInitializer.SeedDefaultsAsync(db, cryptoService); } if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error", createScopeForErrors: true); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); app.Run();