using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using CallCenterApi.Model;

namespace CallCenterApi.BLL
{
    public class T_CTI_TaskAgent
    {
        private readonly CallCenterApi.DAL.T_CTI_TaskAgent dal = new CallCenterApi.DAL.T_CTI_TaskAgent();
        public T_CTI_TaskAgent()
        { }
        #region  Method


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(CallCenterApi.Model.T_CTI_TaskAgent model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

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

        public bool Update(Model.T_CTI_TaskAgent model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CallCenterApi.Model.T_CTI_TaskAgent GetModel(int taskId)
        {
            return dal.GetModel(taskId);
        }


    }
    #endregion  Method
}

