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

namespace CallCenterApi.DAL
{
    public class CallRecords
    {
        public CallRecords()
        { }
        #region  BasicMethod
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.CallResult DataRowToModel(DataRow row)
        {
            Model.CallResult model = new Model.CallResult();
            if (row != null)
            {
                model.Id = row["Id"] == DBNull.Value ? 0 : Convert.ToInt32(row["Id"]);
                model.TaskId = row["itemid"] == DBNull.Value ? 0 : Convert.ToInt32(row["itemid"]);
                model.CallNumber = row["Callee"] == DBNull.Value ? "" : row["Callee"].ToString();
                model.Usercode = row["AgentId"] == DBNull.Value ? "" : row["AgentId"].ToString();
                model.StartDate = row["StartDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["StartDate"].ToString());
                model.GetInAgentDate = row["GetInAgentDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["GetInAgentDate"].ToString());
                model.EndDate = row["EndDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["EndDate"].ToString());
                model.RecordPath = row["RecordPath"] == DBNull.Value ? "" : row["RecordPath"].ToString();
                model.Username = row["Username"] == DBNull.Value ? "" : row["Username"].ToString();
                model.State = row["State"] == DBNull.Value ? "" : row["State"].ToString();
                model.TalkTime = row["TalkTime"] == DBNull.Value ? 0 : Convert.ToInt32(row["TalkTime"]);
            }
            return model;
        }

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}
