using Dapper;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using Shared.DTO;
using System.Data;

namespace DAL
{
    public class MedicionScadaRepository
    {
        private readonly IConfiguration _configuration;

        public MedicionScadaRepository(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        public async Task<List<MedicionScada>> ObtenerMedicionesAsync()
        {
            var connectionString = _configuration.GetConnectionString("DefaultConnection");
            await using var connection = new SqlConnection(connectionString);

            var result = await connection.QueryAsync<MedicionScada>(
                "SP_OBTENER_MEDICION_SMARTSCADA_OPERACION",
                commandType: CommandType.StoredProcedure);

            return result.ToList();
        }
    }
}
