using MMoneyCoderSharp.Data.Request;
using MMoneyCoderSharp.DB;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MMoneyCoderSharp.Data;

namespace MMoneyCoderSharp.Data.Request
{
    /// <summary>
    /// Data Access Object 
    /// </summary>
    public abstract class Nxt_ADataObject : Nxt_IDataRequest
    {

        public Nxt_ADataObject()
        {
            Nxt_mRequestQuery = new Dictionary<string, string>();
            Nxt_mReturnDataSet = new DataSet();
        }

        /// <summary>
        /// 완성되어 DB로 전송될 쿼리
        /// </summary>
        protected Dictionary<string, string> Nxt_mRequestQuery = new Dictionary<string, string>();

        /// <summary>
        /// 완성되어 결과를 리턴할 데이터 셋
        /// </summary>
        protected DataSet Nxt_mReturnDataSet = null;

        public string Nxt_getQuery(string tableName)
        {
            return Nxt_mRequestQuery[tableName];
        }

        public abstract Nxt_IDataRequest Nxt_buildData();

        public DataSet Nxt_getResult()
        {
            foreach (KeyValuePair<string, string> item in Nxt_mRequestQuery)
            {
                Nxt_mReturnDataSet.Tables.Add(
                    DataQueryExecutor.Current.Execute(DataSourceKind.MariaDb, item.Key, item.Value));
            }

            return Nxt_mReturnDataSet;
        }
    }
}
