1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 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<HRDataContext>(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<RolePermission>), typeof(RolePermissionRepository));
- services.AddScoped(typeof(IUserRoleRepository<IdentityUserRole<string>>), typeof(UserRoleRepository));
- services.AddScoped<IUnitOfWork, UnitOfWork>();
- services.AddScoped<IUnitOfWorkLog, UnitOfWorkLog>();
- services.AddScoped<ApplicationUserManager>();
- services.AddScoped<GlobalInfo>();
- services.AddScoped<IEmployeeRepository, EmployeeRepository>();
- return services;
- }
- }
- }
|