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

namespace RMYY_CallCenter_Api.Bll
{
  public   class T_WowoRepair_Basebll
    {
        private readonly Dal.T_WowoRepair_Basedal dal = new Dal.T_WowoRepair_Basedal();
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string T_Wowocodeid)
        {
            return dal.Exists(T_Wowocodeid);
        }
        #region 添加

        /// <summary>
        /// 增加一条报修工单数据
        /// </summary>
        public int Addrepair(RMYY_CallCenter_Api.Model.T_WowoRepair_Base model)
        {
            return dal.Addrepair(model);
        }

        /// <summary>
        /// 增加一条派单数据
        /// </summary>
        public int Addrepairsend(RMYY_CallCenter_Api.Model.T_Wowo_repair_send model)
        {
            return dal.Addrepairsend(model);
        }

        /// <summary>
        /// 增加一条工单流程数据
        /// </summary>
        public int Addrepairitems(RMYY_CallCenter_Api.Model.T_Wowo_repair_items model)
        {
            return dal.Addrepairitems(model);
        }
        /// <summary>
        /// 上传一张工单图片
        /// </summary>
        public int Addrepairimg(RMYY_CallCenter_Api.Model.T_Wowo_repair_img model)
        {
            return dal.Addrepairimg(model);
        }
        /// <summary>
        /// 获取图片信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List<RMYY_CallCenter_Api.Model.T_Wowo_repair_img> Getrepairimg(string id)
        {
            return dal.Getrepairimg(id);

        }
        /// <summary>
        /// 评价
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Addrepairevaluate(RMYY_CallCenter_Api.Model.T_Wowo_repair_evaluate model)
        {
            return dal.Addrepairevaluate(model);
        }
        #endregion
        #region 修改
        /// <summary>
        /// 更新一条报修工单数据
        /// </summary>
        public bool Updaterepair(RMYY_CallCenter_Api.Model.T_WowoRepair_Base model)
        {
            return dal.Updaterepair(model);
        }

        #endregion
        #region 删除
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Deleterepair(int T_Wowocodeid)
        {

            return dal.Deleterepair(T_Wowocodeid);
        }

        #endregion
        #region 查询
        /// <summary>
        /// 得到一个工单对象实体
        /// </summary>
        public RMYY_CallCenter_Api.Model.T_WowoRepair_Base GetModel(int T_Wowocodeid)
        {
            return dal.GetModel(T_Wowocodeid);
        }
        /// <summary>
        /// 分页获取工单数据列表
        /// </summary>
        public List<RMYY_CallCenter_Api.Model.T_WowoRepair_Base> GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            DataSet ds= dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获取报表所需信息
        /// </summary>
        /// <param name="strwhere"></param>
        /// <returns></returns>
        public List<RMYY_CallCenter_Api.Model.T_WowoRepair_Base> GetListRepairlistall(string strwhere)
        {
            DataSet ds = dal.GetListRepairlistall(strwhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得工单数据列表
        /// </summary>
        public List<RMYY_CallCenter_Api.Model.T_WowoRepair_Base> DataTableToList(DataTable dt)
        {
            List<RMYY_CallCenter_Api.Model.T_WowoRepair_Base> modelList = new List<RMYY_CallCenter_Api.Model.T_WowoRepair_Base>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                RMYY_CallCenter_Api.Model.T_WowoRepair_Base model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        /// <summary>
        /// 获取工单流程信息
        /// </summary>
        /// <param name="T_Wowocodeid"></param>
        /// <returns></returns>
        public List<T_Wowo_repair_items> Getworderitems(int T_Wowocodeid)
        {
            DataSet ds= dal.Getworderitems(T_Wowocodeid);
            return DataTableitemsToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得工单流程列表
        /// </summary>
        public List<RMYY_CallCenter_Api.Model.T_Wowo_repair_items> DataTableitemsToList(DataTable dt)
        {
            List<RMYY_CallCenter_Api.Model.T_Wowo_repair_items> modelList = new List<RMYY_CallCenter_Api.Model.T_Wowo_repair_items>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                RMYY_CallCenter_Api.Model.T_Wowo_repair_items model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToitemModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        /// <summary>
        /// 获取派单记录
        /// </summary>
        /// <param name="T_Wowocodeid"></param>
        /// <returns></returns>
        public List<RMYY_CallCenter_Api.Model.T_Wowo_repair_send> Getwordersend(int T_Wowocodeid)
        {
            DataSet ds= dal.Getwordersend(T_Wowocodeid);
            return DataTablesendToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获取派单记录
        /// </summary>
        public List<RMYY_CallCenter_Api.Model.T_Wowo_repair_send> DataTablesendToList(DataTable dt)
        {
            List<RMYY_CallCenter_Api.Model.T_Wowo_repair_send> modelList = new List<RMYY_CallCenter_Api.Model.T_Wowo_repair_send>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                RMYY_CallCenter_Api.Model.T_Wowo_repair_send model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowTosendModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
        /// <summary>
        /// 获取评价信息
        /// </summary>
        /// <param name="T_Wowocodeid"></param>
        /// <returns></returns>
        public DataSet Getworderevaluate(int T_Wowocodeid)
        {
            return dal.Getworderevaluate(T_Wowocodeid);
        }
        /// <summary>
        /// 获取评价信息
        /// </summary>
        public List<RMYY_CallCenter_Api.Model.T_Wowo_repair_evaluate> DataTableevaluateToList(DataTable dt)
        {
            List<RMYY_CallCenter_Api.Model.T_Wowo_repair_evaluate> modelList = new List<RMYY_CallCenter_Api.Model.T_Wowo_repair_evaluate>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                RMYY_CallCenter_Api.Model.T_Wowo_repair_evaluate model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToevaluateModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获取维运报表数据信息
        /// </summary>
        /// <returns></returns>
        public List<RMYY_CallCenter_Api.Model.T_WowoRepair_Base> GetZhwyworktable(string stime,string etime,int typeid,string  key)
        {
            DataSet ds = dal.GetZhwyworktable(stime,etime,typeid,key);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获取数量
        /// </summary>
        /// <returns></returns>
        public int getcount(string datable ,string strWhere,string stime,string etime )
        {
            return dal.getcount(datable,strWhere,stime,etime);
        }
        #endregion
    }
}
