using FluentValidation; using GozareshgirProgramManager.Application._Common.Behaviors; using GozareshgirProgramManager.Application._Common.Interfaces; using GozareshgirProgramManager.Domain._Common; using GozareshgirProgramManager.Domain.CheckoutAgg.Repositories; using GozareshgirProgramManager.Domain.CustomerAgg.Repositories; using GozareshgirProgramManager.Domain.ProjectAgg.Repositories; using GozareshgirProgramManager.Domain.RoleAgg.Repositories; using GozareshgirProgramManager.Domain.RoleAgg.Repositories; using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories; using GozareshgirProgramManager.Domain.SalaryPaymentSettingAgg.Repositories; using GozareshgirProgramManager.Domain.SkillAgg.Repositories; using GozareshgirProgramManager.Domain.SkillAgg.Repositories; using GozareshgirProgramManager.Domain.UserAgg.Repositories; using GozareshgirProgramManager.Infrastructure.Persistence; using GozareshgirProgramManager.Infrastructure.Persistence.Context; using GozareshgirProgramManager.Infrastructure.Persistence.Repositories; using GozareshgirProgramManager.Infrastructure.Services.Authentication; using GozareshgirProgramManager.Infrastructure.Services.Role; using GozareshgirProgramManager.Infrastructure.Services.User; using MediatR; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Shared.Contracts.PmRole.Commands; using Shared.Contracts.PmRole.Queries; using Shared.Contracts.PmUser; namespace GozareshgirProgramManager.Infrastructure; public static class DependencyInjection { public static IServiceCollection AddProgramManagerInfrastructure( this IServiceCollection services, IConfiguration configuration) { // DbContext services.AddDbContext(options => options.UseSqlServer( configuration.GetConnectionString("ProgramManagerDb"), b => b.MigrationsAssembly(typeof(ProgramManagerDbContext).Assembly.FullName))); // Register IAppDbContext services.AddScoped(provider => provider.GetRequiredService()); // Unit of Work services.AddScoped(); //Users services.AddScoped(); //Roles services.AddScoped(); //WorkingHours services.AddScoped(); //Checkout services.AddScoped(); // Repositories services.AddScoped(); // Legacy Project repositories services.AddScoped(); // New Hierarchy repositories services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); services.AddScoped(); // JWT Settings services.Configure(configuration.GetSection("JwtSettings")); // Authentication Services services.AddScoped(); services.AddScoped(); #region ServicesInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); #endregion // MediatR Validation Behavior services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>)); return services; } }