diff --git a/MoneyMap/Program.cs b/MoneyMap/Program.cs index a478362..485cdd5 100644 --- a/MoneyMap/Program.cs +++ b/MoneyMap/Program.cs @@ -10,6 +10,15 @@ builder.Services.AddRazorPages(); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("MoneyMapDb"))); +// Add session support +builder.Services.AddDistributedMemoryCache(); +builder.Services.AddSession(options => +{ + options.IdleTimeout = TimeSpan.FromMinutes(30); + options.Cookie.HttpOnly = true; + options.Cookie.IsEssential = true; +}); + // Add the new services here builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -25,6 +34,13 @@ builder.Services.AddHttpClient(); var app = builder.Build(); +// Seed default category mappings on startup +using (var scope = app.Services.CreateScope()) +{ + var categorizer = scope.ServiceProvider.GetRequiredService(); + await categorizer.SeedDefaultMappingsAsync(); +} + // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { @@ -37,6 +53,8 @@ app.UseStaticFiles(); app.UseRouting(); +app.UseSession(); + app.UseAuthorization(); app.MapRazorPages();