using RDH.Data.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace RDH.Data.BLL
{
    public partial class OperationTakeItemBagBLL : BaseOrclSnapshotBLL<OperationTakeItemBag>
    {
        public OperationTakeItemBagBLL() : base()
        {
            AliasTableName = "otib";
        }

        internal override String TABLE_NAME { get { return "OPERATION_TAKE_ITEM_BAG"; } }//TB_NAME
        internal override string ENTITY_NAME { get { return "OperationTakeItemBag"; } }
        internal override String KEY_COLUMN { get { return "SNAPSHOT_KEY"; } }//KEY_COLUMN
        internal override string SNAPSHOT_BASE { get { return "OPERATION_TAKE_ITEM_BAG_BASE"; } }

        internal override void InitMaps()
        {
            ColumnPropMaps.Add("KEY", "Key");
            ColumnPropMaps.Add("SNAPSHOT_KEY", "SnapshotKey");
            ColumnPropMaps.Add("OPERATION_KEY", "OperationKey");
            ColumnPropMaps.Add("NAME", "Name");
            ColumnPropMaps.Add("TYPE", "Type");
            ColumnPropMaps.Add("STATUS", "Status");
            //ColumnPropMaps.Add("DESC", "Desc");
            ColumnPropMaps.Add("CREATE_BY", "CreateBy");
            ColumnPropMaps.Add("CREATE_TIME", "CreateTime");
            ColumnPropMaps.Add("ITEM_COUNT", "ItemCount");
            ColumnPropMaps.Add("CHECKED_COUNT", "CheckedCount");
            ColumnPropMaps.Add("UPLOADED_COUNT", "UploadedCount");
            ColumnPropMaps.Add("FLAG", "Flag");
            ColumnPropMaps.Add("CLIENT_TIME", "ClientTime");
            ColumnPropMaps.Add("SERVER_TIME", "ServerTime");
            ColumnPropMaps.Add("EXT01", "Ext01");
            ColumnPropMaps.Add("EXT02", "Ext02");
            ColumnPropMaps.Add("EXT03", "Ext03");
            ColumnPropMaps.Add("EXT04", "Ext04");
            ColumnPropMaps.Add("EXT05", "Ext05");
            ColumnPropMaps.Add("EXT06", "Ext06");
            ColumnPropMaps.Add("EXT07", "Ext07");
            ColumnPropMaps.Add("EXT08", "Ext08");
            ColumnPropMaps.Add("EXT09", "Ext09");
            ColumnPropMaps.Add("EXT10", "Ext10");
            ColumnPropMaps.Add("DEVICE_KEY", "DeviceKey");//COLUMN_MAPS
        }

        internal override object GetParam(OperationTakeItemBag operationtakeitembag)
        {
            return new
            {
                Key = operationtakeitembag.Key,
                SnapshotKey = operationtakeitembag.SnapshotKey,
                OperationKey = operationtakeitembag.OperationKey,
                Name = operationtakeitembag.Name,
                Type = operationtakeitembag.Type,
                Status = operationtakeitembag.Status,
                Desc = operationtakeitembag.Desc,
                CreateBy = operationtakeitembag.CreateBy,
                CreateTime = operationtakeitembag.CreateTime,
                ItemCount = operationtakeitembag.ItemCount,
                CheckedCount = operationtakeitembag.CheckedCount,
                UploadedCount = operationtakeitembag.UploadedCount,
                Flag = operationtakeitembag.Flag,
                ClientTime = operationtakeitembag.ClientTime,
                ServerTime = operationtakeitembag.ServerTime,
                Ext01 = operationtakeitembag.Ext01,
                Ext02 = operationtakeitembag.Ext02,
                Ext03 = operationtakeitembag.Ext03,
                Ext04 = operationtakeitembag.Ext04,
                Ext05 = operationtakeitembag.Ext05,
                Ext06 = operationtakeitembag.Ext06,
                Ext07 = operationtakeitembag.Ext07,
                Ext08 = operationtakeitembag.Ext08,
                Ext09 = operationtakeitembag.Ext09,
                Ext10 = operationtakeitembag.Ext10,
                DeviceKey = operationtakeitembag.DeviceKey,   //Params
            };
        }
        public OperationTakeItemBag GetByOperation(PatientOperationInfo operationInfo) 
        {
            return SqlMapper.Query<OperationTakeItemBag>(ConnectionFactory.Current.GetSessionConnection(),
                BuildBaseSql() + " WHERE OPERATION_KEY=:operationKey",
                new { operationKey = operationInfo.Key })
                .FirstOrDefault();
        }
    }
}
