using Knoks.Core.Data.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Knoks.Core.Entities;
using Knoks.Core.Entities.Args;
using Knoks.Framework.DataAccess;
using Microsoft.Extensions.Logging;

namespace Knoks.Core.Data.Dao
{
    public class SystemConfigurationDao : ISystemConfigurationDao
    {
        private readonly IProcExecutor _executor;
        private readonly ILogger<SystemConfigurationDao> _logger;

        public SystemConfigurationDao(ILogger<SystemConfigurationDao> logger, IProcExecutor executor)
        {
            _logger = logger;
            _executor = executor;
        }

        public async Task<SystemConfiguration> GetSystemConfiguration()
        {
            return (await _executor.Go("SYS_GetSystemConfiguration"))
                .Тables[0][0].To<SystemConfiguration>();
        }

        public async Task<SystemConfiguration> UpdateSystemConfiguration(SystemConfigurationArgs args)
        {
            return (await _executor.Go("SYS_UpdateSystemConfiguration", args))
               .Тables[0][0].To<SystemConfiguration>();
        }
    }
}
