From 5c6860a4ad858ee95217130f32fa38c5b4b594d5 Mon Sep 17 00:00:00 2001 From: beo3000 Date: Tue, 23 Dec 2025 11:20:18 +0100 Subject: [PATCH] mod DI Containers --- docs/IMPLEMENTATION_PLAN.md | 2 +- src/Koogle.Application/DependencyInjection.cs | 9 ++++---- .../DependencyInjection.cs | 22 +++++++++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/docs/IMPLEMENTATION_PLAN.md b/docs/IMPLEMENTATION_PLAN.md index 8040ac4..8facc85 100644 --- a/docs/IMPLEMENTATION_PLAN.md +++ b/docs/IMPLEMENTATION_PLAN.md @@ -329,7 +329,7 @@ NavMenu.razor: | ✓ | A4 | Foundation | Service Interfaces | 5 Service-Interface-Dateien | | ✓ | A5 | Foundation | Service Implementations | 5 Service-Dateien | | ✓ | A6 | Foundation | AutoMapper Profiles | 5 Mapping-Dateien | -| ☐ | A7 | Foundation | DI Registration | 2 DI-Dateien ändern | +| ✓ | A7 | Foundation | DI Registration | 2 DI-Dateien ändern | | ☐ | **B1** | **Clubs** | **ClubState Fluxor** | **4 State-Dateien** | | ☐ | **B2** | **Clubs** | **Club Pages - ERSTES TESTBARES MVP** | **1 Razor** | | ☐ | C1 | User/Account | UserService erweitern | 1 Service, 1 Interface, 1 DTO | diff --git a/src/Koogle.Application/DependencyInjection.cs b/src/Koogle.Application/DependencyInjection.cs index e95bb77..9df2281 100644 --- a/src/Koogle.Application/DependencyInjection.cs +++ b/src/Koogle.Application/DependencyInjection.cs @@ -21,12 +21,13 @@ namespace Koogle.Application // Application Services - //services.AddScoped(); - //services.AddScoped(); - //services.AddScoped(); services.AddScoped(); services.AddScoped(); - //services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); return services; } diff --git a/src/Koogle.Infrastructure/DependencyInjection.cs b/src/Koogle.Infrastructure/DependencyInjection.cs index a907799..bdba4fa 100644 --- a/src/Koogle.Infrastructure/DependencyInjection.cs +++ b/src/Koogle.Infrastructure/DependencyInjection.cs @@ -2,19 +2,14 @@ using Koogle.Infrastrcuture.Services; using Koogle.Infrastructure.Data; using Koogle.Infrastructure.Identity; +using Koogle.Infrastructure.Repositories; +using Koogle.Infrastructure.Security; using KoogleApp.Data; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Koogle.Infrastructure.Security; namespace Koogle.Infrastructure; public static class DependencyInjection @@ -35,6 +30,13 @@ public static class DependencyInjection sql.MigrationsHistoryTable("__EFMigrationsHistory_App", "app"); })); + // DbContext Factory for scoped contexts in services + services.AddDbContextFactory(options => + options.UseSqlServer(conn, sql => + { + sql.MigrationsHistoryTable("__EFMigrationsHistory_App", "app"); + }), ServiceLifetime.Scoped); + // Identity DbContext (auth schema) services.AddDbContext(options => options.UseSqlServer(conn, sql => @@ -75,6 +77,12 @@ public static class DependencyInjection // Current UserProfile Service services.AddScoped(); + // Repositories + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); services.AddCascadingAuthenticationState();