Integracion_DGA/DAL/MedicionDGARepository.cs

38 lines
1.2 KiB
C#
Raw Normal View History

using System.Data;
using Dapper;
2025-06-24 14:46:32 -04:00
using Microsoft.Data.SqlClient;
using Shared.DTO.Envios_DGA;
2025-07-01 09:59:59 -04:00
using Shared.DTO.VariablesEntorno;
2025-06-24 14:46:32 -04:00
namespace DAL
{
2025-07-16 20:39:24 -04:00
public class MedicionDGARepository
2025-06-24 14:46:32 -04:00
{
2025-07-16 20:39:24 -04:00
public async Task<List<DatoDGA>> ObtenerMedicionesAsync()
2025-06-24 14:46:32 -04:00
{
2025-07-01 09:59:59 -04:00
await using var connection = new SqlConnection(BdConexion.StringConnection);
2025-06-24 14:46:32 -04:00
2025-07-16 20:39:24 -04:00
var result = await connection.QueryAsync<DatoDGA>(
"SP_OBTENER_DGA_DATOS",
2025-06-24 14:46:32 -04:00
commandType: CommandType.StoredProcedure);
return result.ToList();
}
public static async Task<bool> ActualizarMedicionesAsync(string medicionesJson)
{
2025-07-17 09:22:55 -04:00
//TODO: ACTUALIZAR REGISTROS
try
{
await using var connection = new SqlConnection(BdConexion.StringConnection);
await connection.ExecuteAsync("SP_ACTUALIZAR_MEDICION_SMARTSCADA_OPERACION", new { JsonMediciones = medicionesJson }, commandType: CommandType.StoredProcedure);
return true;
}
catch (Exception ex)
{
throw new Exception($"Error: {ex.Message}");
}
}
2025-06-24 14:46:32 -04:00
}
}