InfrastructureServiceRegistration.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Microsoft.Extensions.DependencyInjection;
  2. using Microsoft.Extensions.Configuration;
  3. using MTWorkHR.Infrastructure.EmailService;
  4. using MTWorkHR.Infrastructure.Logging;
  5. using MTWorkHR.Core.Global;
  6. using Microsoft.AspNetCore.Identity;
  7. using Microsoft.EntityFrameworkCore;
  8. using MTWorkHR.Core.IRepositories.Base;
  9. using MTWorkHR.Core.IRepositories;
  10. using MTWorkHR.Core.UnitOfWork;
  11. using MTWorkHR.Identity.Entities;
  12. using MTWorkHR.Infrastructure.Data;
  13. using MTWorkHR.Infrastructure.Repositories;
  14. using MTWorkHR.Infrastructure.UnitOfWorks;
  15. using MTWorkHR.Core.Email;
  16. namespace MTWorkHR.Infrastructure
  17. {
  18. public static class InfrastructureServiceRegistration
  19. {
  20. public static IServiceCollection AddInfrastructureServices (this IServiceCollection services, AppSettingsConfiguration configuration){
  21. services.AddDbContext<HRDataContext>(options => {
  22. options.UseSqlServer(configuration.ConnectionStrings.MTWorkHRConnectionString);
  23. });
  24. services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
  25. services.AddScoped(typeof(IRepositoryLog<>), typeof(RepositoryLog<>));
  26. services.AddScoped(typeof(ICompanyRepository), typeof(CompanyRepository));
  27. services.AddScoped(typeof(IProjectRepository), typeof(ProjectRepository));
  28. services.AddScoped(typeof(ITaskStatusRepository), typeof(TaskStatusRepository));
  29. services.AddScoped(typeof(IUserTaskRepository), typeof(UserTaskRepository));
  30. services.AddScoped(typeof(IUserTaskHistoryRepository), typeof(UserTaskHistoryRepository));
  31. services.AddScoped(typeof(IPermissionRepository), typeof(PermissionRepository));
  32. services.AddScoped(typeof(IRolePermissionRepository<RolePermission>), typeof(RolePermissionRepository));
  33. services.AddScoped(typeof(IUserRoleRepository<IdentityUserRole<string>>), typeof(UserRoleRepository));
  34. services.AddScoped<IUnitOfWork, UnitOfWork>();
  35. services.AddScoped<IUnitOfWorkLog, UnitOfWorkLog>();
  36. services.AddTransient<IMailSender, MailSender>();
  37. services.AddScoped<ApplicationUserManager>();
  38. services.AddScoped<GlobalInfo>();
  39. services.AddScoped<IEmployeeRepository, EmployeeRepository>();
  40. //services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>));
  41. return services;
  42. }
  43. }
  44. }