2026-01-08 03:59:38 +00:00
|
|
|
namespace Adapters.Driven.Persistence;
|
|
|
|
|
|
|
|
|
|
using Adapters.Driven.Persistence.Context;
|
|
|
|
|
using Adapters.Driven.Persistence.Repositories;
|
2026-01-08 14:14:42 +00:00
|
|
|
using Adapters.Driven.Persistence.Services;
|
|
|
|
|
using Application.Auth;
|
2026-01-08 03:59:38 +00:00
|
|
|
using Domain.Ports.Repositories;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
public static class DependencyInjection
|
|
|
|
|
{
|
|
|
|
|
public static IServiceCollection AddPersistence(
|
|
|
|
|
this IServiceCollection services,
|
|
|
|
|
IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
services.AddDbContext<AppDbContext>(options =>
|
|
|
|
|
options.UseSqlServer(
|
|
|
|
|
configuration.GetConnectionString("DefaultConnection"),
|
|
|
|
|
b => b.MigrationsAssembly(typeof(AppDbContext).Assembly.FullName)));
|
|
|
|
|
|
2026-01-08 14:14:42 +00:00
|
|
|
// Repositories
|
2026-01-08 03:59:38 +00:00
|
|
|
services.AddScoped<IStudentRepository, StudentRepository>();
|
|
|
|
|
services.AddScoped<ISubjectRepository, SubjectRepository>();
|
|
|
|
|
services.AddScoped<IProfessorRepository, ProfessorRepository>();
|
|
|
|
|
services.AddScoped<IEnrollmentRepository, EnrollmentRepository>();
|
2026-01-08 14:14:42 +00:00
|
|
|
services.AddScoped<IUserRepository, UserRepository>();
|
2026-01-08 03:59:38 +00:00
|
|
|
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
|
|
|
|
|
2026-01-08 14:14:42 +00:00
|
|
|
// Auth services
|
|
|
|
|
services.AddScoped<IJwtService, JwtService>();
|
|
|
|
|
services.AddScoped<IPasswordService, PasswordService>();
|
|
|
|
|
|
2026-01-08 03:59:38 +00:00
|
|
|
return services;
|
|
|
|
|
}
|
|
|
|
|
}
|