37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using Application.Services.Database;
|
|
using Application.Services.HashingAlgorithms;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Services.HashingAlgorithms;
|
|
using Infrastructure.Services.MongoDB;
|
|
using Infrastructure.Services.PostgreSQL;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Infrastructure;
|
|
|
|
public static class DependencyInjection
|
|
{
|
|
public static IServiceCollection AddInfrastructureServices(this IServiceCollection services,
|
|
IConfiguration configuration)
|
|
{
|
|
services.AddDbContext<HealthcareManagerDatabase>(options =>
|
|
options.UseNpgsql(configuration.GetConnectionString("HealthcareManagerDatabase")));
|
|
|
|
//PostgreSQL Services
|
|
services.AddScoped<IPatientRepository, PatientRepository>();
|
|
services.AddScoped<IDoctorRepository, DoctorRepository>();
|
|
services.AddScoped<IMedicalHistoryRepository, MedicalHistoryRepository>();
|
|
|
|
// MongoDB Service
|
|
var mongoDbConnection = configuration.GetConnectionString("MongoDBDatabase");
|
|
services.AddSingleton<IMongoDbService>(serviceProvider => new MongoDbService(mongoDbConnection));
|
|
|
|
|
|
// Other Services
|
|
services.AddScoped<IHashingAlgorithms, HashingAlgorithms>();
|
|
// services.AddScoped<IEmailService, EmailService>();
|
|
|
|
return services;
|
|
}
|
|
} |