feat: se centralizan las variables de entorno y utilidades, ademas de agregar entidades para poder hacer más legible el codigo

This commit is contained in:
Leonel Toro 2025-07-01 01:33:49 -04:00
parent bffcdabc0a
commit 222d5fdc08
14 changed files with 203 additions and 59 deletions

View file

@ -9,25 +9,25 @@ using System.Text;
using System.Threading.Tasks;
using Dapper;
using Microsoft.Extensions.Configuration;
using Shared.Utils.Variables_Entorno;
namespace DAL
{
public class JobsDgaRepository
{
private static string connectionString = string.Empty;
private readonly IConfiguration _configuration;
public JobsDgaRepository(IConfiguration configuration)
private readonly BD_Conexion _bdConexion;
public JobsDgaRepository(IConfiguration configuration,BD_Conexion bdConexion)
{
_configuration = configuration;
connectionString = _configuration.GetConnectionString("DefaultConnection") ?? "";
_bdConexion = bdConexion;
}
public async Task<bool> InsertarDgaMacroResultado(List<DgaMacroResultado> dgaMacroResultados)
{
try
{
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlConnection connection = new SqlConnection(_bdConexion.stringConnection))
{
await connection.OpenAsync();
// 1. Truncar la tabla antes de insertar
@ -49,7 +49,7 @@ namespace DAL
{
try
{
using (var connection = new SqlConnection(connectionString))
using (var connection = new SqlConnection(_bdConexion.stringConnection))
{
await connection.OpenAsync();
@ -77,7 +77,7 @@ namespace DAL
try
{
// Configurar la conexión a la base de datos
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlConnection connection = new SqlConnection(_bdConexion.stringConnection))
{
await connection.OpenAsync();
// Truncar la tabla antes de insertar
@ -102,7 +102,7 @@ namespace DAL
{
try
{
using (var connection = new SqlConnection(connectionString))
using (var connection = new SqlConnection(_bdConexion.stringConnection))
{
await connection.OpenAsync();
// Ejecuta el stored procedure sin parámetros
@ -120,7 +120,7 @@ namespace DAL
{
try
{
using (var connection = new SqlConnection(connectionString))
using (var connection = new SqlConnection(_bdConexion.stringConnection))
{
await connection.OpenAsync();
await connection.ExecuteAsync(
@ -140,7 +140,7 @@ namespace DAL
{
try
{
using (var connection = new SqlConnection(connectionString))
using (var connection = new SqlConnection(_bdConexion.stringConnection))
{
await connection.OpenAsync();
await connection.ExecuteAsync(