In progress
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using ColaFlow.Modules.Identity.Domain.Repositories;
|
||||
using ColaFlow.Modules.Identity.Infrastructure.Persistence;
|
||||
using ColaFlow.Modules.Identity.Infrastructure.Persistence.Repositories;
|
||||
using ColaFlow.Modules.Identity.Infrastructure.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace ColaFlow.Modules.Identity.Infrastructure;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddIdentityInfrastructure(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
// DbContext (using connection string)
|
||||
services.AddDbContext<IdentityDbContext>(options =>
|
||||
options.UseNpgsql(
|
||||
configuration.GetConnectionString("DefaultConnection"),
|
||||
b => b.MigrationsAssembly(typeof(IdentityDbContext).Assembly.FullName)));
|
||||
|
||||
// Tenant Context (Scoped - one instance per request)
|
||||
services.AddScoped<ITenantContext, TenantContext>();
|
||||
services.AddHttpContextAccessor(); // Required for HttpContext access
|
||||
|
||||
// Repositories
|
||||
services.AddScoped<ITenantRepository, TenantRepository>();
|
||||
services.AddScoped<IUserRepository, UserRepository>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user