using Dapper;
using System;
using System.Data;

namespace WK_KLI_LAPS_Service.App_Data
{
    public class WorkAreaRepository
    {
        CommonRepository oCommonRepository = new CommonRepository();

        public object GetChecklistdetail(int tranid)
        {
            using (IDbConnection dbConnection = ConnectionBase.Connection)
            {
                DynamicParameters param = new DynamicParameters();
                //var checkparam = new { p_tranid = tranid };
                //var jsonstr = JsonConvert.SerializeObject(checkparam);
                param.Add("p_tranid", tranid);
                //param.Add("mode_p", "getusersbydepartment");
                dbConnection.Open();
                return dbConnection.Query<string>("spchecklisttransactionselect", param, commandType: CommandType.StoredProcedure);
            }
        }
        public int GetPreviousStageTranid(int tranid)
        {
            int retval = 0;
            using (IDbConnection dbConnection = ConnectionBase.Connection)
            {
                DynamicParameters param = new DynamicParameters();
                //var checkparam = new { p_tranid = tranid };
                //var jsonstr = JsonConvert.SerializeObject(checkparam);
                param.Add("p_tranid", tranid);
                //param.Add("mode_p", "getusersbydepartment");
                dbConnection.Open();
                using (var transaction = dbConnection.BeginTransaction())
                {

                    object d = dbConnection.ExecuteScalar("spgetpreviousstageTranid", param, commandType: CommandType.StoredProcedure);
                    if (d != null)
                    {
                        retval = Convert.ToInt32(d.ToString());
                    }
                }
            }
            return retval;

        }
    }
}
