using Microsoft.Extensions.DependencyInjection; using Microsoft.EntityFrameworkCore; using MTWorkHR.Infrastructure.Data; using Microsoft.Extensions.Configuration; using MTWorkHR.Core.IRepositories.Base; using MTWorkHR.Infrastructure.Repositories; using MTWorkHR.Core.IRepositories; using MTWorkHR.Identity.Models; using Microsoft.AspNetCore.Identity; using MTWorkHR.Core.UnitOfWork; using MTWorkHR.Infrastructure.UnitOfWorks; using MTWorkHR.Core.Global; namespace MTWorkHR.Infrastructure { public static class PersistenceServiceRegistration { public static IServiceCollection AddPersistenceServices (this IServiceCollection services, IConfiguration configuration){ services.AddDbContext(options => { options.UseSqlServer(configuration.GetSection("ConnectionStrings:MTWorkHRConnectionString").Value); }); services.AddScoped(typeof(IRepository<>), typeof(Repository<>)); services.AddScoped(typeof(IRepositoryLog<>), typeof(RepositoryLog<>)); services.AddScoped(typeof(IPermissionRepository), typeof(PermissionRepository)); services.AddScoped(typeof(IRolePermissionRepository), typeof(RolePermissionRepository)); services.AddScoped(typeof(IUserRoleRepository>), typeof(UserRoleRepository)); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); return services; } } }