using Dapper;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace e_suite.Service.SigmaImporter.Repository;

public interface ISigmaAirlockRepository
{
    Task<IEnumerable<SigmaTlaHostName>> GetActivePrintSpecifications();
}

public class SigmaTlaHostName
{
    public string Tla { get; set; } = string.Empty;
    public string Hostname { get; set; } = string.Empty;
}

public class SigmaAirlockRepository : MySqlRepositoryBase, ISigmaAirlockRepository
{
    public SigmaAirlockRepository(IConfiguration configuration, ILogger logger) : base(configuration, logger, "SigmaAirlock")
    {
    }

    public async Task<IEnumerable<SigmaTlaHostName>> GetActivePrintSpecifications()
    {
        try
        {
            var result = await Connection.QueryAsync<SigmaTlaHostName>("select distinct\r\n    tla as Tla,\r\n    domain as Hostname\r\nfrom stage_client\r\nwhere tla != ''");
            return result;
        }
        finally
        {
            Close();
        }
    }

}