110 lines
4.2 KiB
C#
110 lines
4.2 KiB
C#
|
|
|
|
|
|
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<ProgramManagerDbContext>(options =>
|
|
options.UseSqlServer(
|
|
configuration.GetConnectionString("ProgramManagerDb"),
|
|
b => b.MigrationsAssembly(typeof(ProgramManagerDbContext).Assembly.FullName)));
|
|
|
|
// Register IAppDbContext
|
|
services.AddScoped<IProgramManagerDbContext>(provider =>
|
|
provider.GetRequiredService<ProgramManagerDbContext>());
|
|
|
|
|
|
// Unit of Work
|
|
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
|
|
|
//Users
|
|
services.AddScoped<IUserRepository, UserRepository>();
|
|
|
|
//Roles
|
|
services.AddScoped<IRoleRepository, RoleRepository>();
|
|
|
|
//WorkingHours
|
|
services.AddScoped<ISalaryPaymentSettingRepository, SalaryPaymentSettingRepository>();
|
|
|
|
//Checkout
|
|
services.AddScoped<ICheckoutRepository, CheckoutRepository>();
|
|
|
|
// Repositories
|
|
services.AddScoped<ICustomerRepository, CustomerRepository>();
|
|
|
|
// Legacy Project repositories
|
|
services.AddScoped<ITaskSectionRepository, TaskSectionRepository>();
|
|
|
|
// New Hierarchy repositories
|
|
services.AddScoped<IProjectRepository, ProjectRepository>();
|
|
services.AddScoped<IProjectPhaseRepository, ProjectPhaseRepository>();
|
|
services.AddScoped<IProjectTaskRepository, ProjectTaskRepository>();
|
|
services.AddScoped<ITaskSectionActivityRepository, TaskSectionActivityRepository>();
|
|
services.AddScoped<IPhaseSectionRepository, PhaseSectionRepository>();
|
|
services.AddScoped<IProjectSectionRepository, ProjectSectionRepository>();
|
|
|
|
services.AddScoped<ISkillRepository, SkillRepository>();
|
|
|
|
services.AddScoped<IUserRefreshTokenRepository, UserRefreshTokenRepository>();
|
|
|
|
// JWT Settings
|
|
services.Configure<JwtSettings>(configuration.GetSection("JwtSettings"));
|
|
|
|
// Authentication Services
|
|
services.AddScoped<JwtTokenGenerator>();
|
|
services.AddScoped<IAuthHelper, AuthHelper>();
|
|
|
|
|
|
|
|
#region ServicesInjection
|
|
|
|
services.AddTransient<IPmRoleQueryService, PmRoleQueryService>();
|
|
|
|
services.AddTransient<IPmRoleCommandService, PmRoleCommandService>();
|
|
services.AddTransient<IPmUserQueryService, PmUserQueryService>();
|
|
|
|
#endregion
|
|
|
|
|
|
// MediatR Validation Behavior
|
|
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehavior<,>));
|
|
|
|
|
|
return services;
|
|
}
|
|
}
|