using System;
using Database.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

namespace Common.Global;

public class DbHelper
{
    private DbContextOptions<ModelContext> GetAllOptions(IConfiguration configuration)
    {
        DbContextOptionsBuilder<ModelContext> optionsBuilder =
            new DbContextOptionsBuilder<ModelContext>();

        string connectionString = configuration.GetSection("Connection").Value!;

        optionsBuilder.UseOracle(connectionString);

        return optionsBuilder.Options;
    }

    public ModelContext GetDbContext(IConfiguration configuration)
    {
        return new ModelContext(GetAllOptions(configuration));
    }
}
