using Dapper;
using EVCB_OCPP.WSServer.Helper;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EVCB_OCPP.WSServer.Service;

public class WebDbService
{
    private readonly SqlConnectionFactory<WebDBConetext> webDbConnectionFactory;

    public WebDbService(SqlConnectionFactory<WebDBConetext> webDbConnectionFactory)
    {
        this.webDbConnectionFactory = webDbConnectionFactory;
        //this.webConnectionString = configuration.GetConnectionString("WebDBContext");
    }

    //private readonly string webConnectionString;

    public async Task<List<string>> GetDenyModelNames()
    {
        return new List<string>() { "" };
        using SqlConnection conn = await webDbConnectionFactory.CreateAsync();
        string strSql = """
                SELECT [Value] 
                FROM [StandardOCPP_Web].[dbo].[KernelConfig]
                where SystemKey = 'DenyModelNames';
                """;

        var result = await conn.QueryFirstOrDefaultAsync<string>(strSql);

        return result.Split(',').ToList();

    }
}
