Integracion_DGA/DAL/MedicionScadaRepository.cs

37 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
{
public class MedicionScadaRepository
{
public async Task<List<MedicionScada>> ObtenerMedicionesAsync()
{
2025-07-01 09:59:59 -04:00
await using var connection = new SqlConnection(BdConexion.StringConnection);
2025-06-24 14:46:32 -04:00
var result = await connection.QueryAsync<MedicionScada>(
"SP_OBTENER_MEDICION_SMARTSCADA_OPERACION",
commandType: CommandType.StoredProcedure);
return result.ToList();
}
public static async Task<bool> ActualizarMedicionesAsync(string medicionesJson)
{
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
}
}