using API.Database; using API.Repository.AgeGroup; using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); // Database var postgreConnection = builder.Configuration.GetConnectionString("PostgresConnection"); if (!string.IsNullOrEmpty(postgreConnection)) { // Nutze PostgresSQL builder.Services.AddDbContext(options => options.UseNpgsql(postgreConnection)); } else { builder.Services.AddDbContext(options => options.UseSqlite("Data Source=app.db")); } // Adding Database Services builder.Services.AddScoped(); // Adding S3 Services // Adding (latler) Redis Services // Add Database Services var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); } using(var scope = app.Services.CreateScope()) { var dbContext = scope.ServiceProvider.GetRequiredService(); dbContext.Database.Migrate(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();