using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

using Infrastructure.Data;
using Infrastructure.Services.MongoDB;
using Application.Services.Database;
using Infrastructure.Services.PostgreSQL;

namespace Infrastructure;

public static class DependencyInjection
{
    public static IServiceCollection AddInfrastructureServices(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddDbContext<HealthcareManagerDatabase>(options =>
            options.UseNpgsql(configuration.GetConnectionString("HealthcareManagerDatabase")));


        services.AddScoped<IPacientRepository, PacientRepository>();
        services.AddScoped<IDoctorRepository, DoctorRepository>();
        services.AddScoped<IMedicalHistoryRepository, MedicalHistoryRepository>();

        var mongoDbConnection = configuration.GetConnectionString("MongoDBDatabase");

        services.AddSingleton(serviceProvider => new MongoDbService(mongoDbConnection));

        // services.AddScoped<IEmailService, EmailService>();

        return services;
    }
}
