mod DI Containers

This commit is contained in:
beo3000 2025-12-23 11:20:18 +01:00
parent be0fa19371
commit 5c6860a4ad
3 changed files with 21 additions and 12 deletions

View File

@ -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 |

View File

@ -21,12 +21,13 @@ namespace Koogle.Application
// Application Services
//services.AddScoped<IDayService, DayService>();
//services.AddScoped<IYearService, YearService>();
//services.AddScoped<ICompanyService, CompanyService>();
services.AddScoped<IUserService, UserService>();
services.AddScoped<ICurrentClubContext, CurrentClubContext>();
//services.AddScoped<IAuthorizationService, AuthorizationService>();
services.AddScoped<IClubService, ClubService>();
services.AddScoped<IPersonService, PersonService>();
services.AddScoped<IExpenseService, ExpenseService>();
services.AddScoped<IDayService, DayService>();
services.AddScoped<IPersonExpenseService, PersonExpenseService>();
return services;
}

View File

@ -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<AppDbContext>(options =>
options.UseSqlServer(conn, sql =>
{
sql.MigrationsHistoryTable("__EFMigrationsHistory_App", "app");
}), ServiceLifetime.Scoped);
// Identity DbContext (auth schema)
services.AddDbContext<AppIdentityDbContext>(options =>
options.UseSqlServer(conn, sql =>
@ -75,6 +77,12 @@ public static class DependencyInjection
// Current UserProfile Service
services.AddScoped<ICurrentUserService, CurrentUserService>();
// Repositories
services.AddScoped<IClubRepository, ClubRepository>();
services.AddScoped<IPersonRepository, PersonRepository>();
services.AddScoped<IExpenseRepository, ExpenseRepository>();
services.AddScoped<IDayRepository, DayRepository>();
services.AddScoped<IPersonExpenseRepository, PersonExpenseRepository>();
services.AddCascadingAuthenticationState();