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

namespace e_suite.Service.SigmaImporter.Repository;

public class SigmaFileBrowserRepository : MySqlRepositoryBase, ISigmaFileBrowserRepository
{
    public SigmaFileBrowserRepository(IConfiguration configuration, ILogger logger) : base(configuration, logger, "SigmaFileBrowser")
    {
    }

    public async Task<IEnumerable<GmgProfile>> GetActiveGmgProfiles()
    {
        try
        {
            var result = await Connection.QueryAsync<GmgProfile>(
                "SELECT DISTINCT\r\n    profile_id as id,\r\n    profile_name as name,\r\n    profile_number as number\r\nFROM profile_info\r\nwhere active = 1");
            return result;
        }
        finally
        {
            Close();
        }
    }
}