using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CallCenterApi.BLL
{
    public class T_CTI_TaskRecord
    {
        DAL.T_CTI_TaskRecord taskRecordDal = new DAL.T_CTI_TaskRecord();
        public long Add(CallCenterApi.Model.T_CTI_TaskRecord model)
        {
            return taskRecordDal.Add(model);
        }

        public DataSet GetList(string strWhere)
        {
            return taskRecordDal.GetList(strWhere);
        }

        public Model.T_CTI_TaskRecord GetModel(int id)
        {
            return taskRecordDal.GetModel(id);
        }

        public bool Update(Model.T_CTI_TaskRecord model)
        {
            return taskRecordDal.Update(model);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<CallCenterApi.Model.T_CTI_TaskRecord> DataTableToList(DataTable dt)
        {
            List<CallCenterApi.Model.T_CTI_TaskRecord> modelList = new List<CallCenterApi.Model.T_CTI_TaskRecord>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                CallCenterApi.Model.T_CTI_TaskRecord model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new CallCenterApi.Model.T_CTI_TaskRecord();
                    if (dt.Rows[n]["Id"] != null && dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    if (dt.Rows[n]["Name"] != null && dt.Rows[n]["Name"].ToString() != "")
                    {
                        model.Name = dt.Rows[n]["Name"].ToString();
                    }
                    if (dt.Rows[n]["RecordTime"] != null && dt.Rows[n]["RecordTime"].ToString() != "")
                    {
                        model.RecordTime = int.Parse(dt.Rows[n]["RecordTime"].ToString());
                    }
                    if (dt.Rows[n]["RecordPath"] != null && dt.Rows[n]["RecordPath"].ToString() != "")
                    {
                        model.RecordPath = dt.Rows[n]["RecordPath"].ToString();
                    }
                    if (dt.Rows[n]["Remark"] != null && dt.Rows[n]["Remark"].ToString() != "")
                    {
                        model.Remark = dt.Rows[n]["Remark"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

    }
}
