using CallCenter.Utility;
using CallCenterApi.Common;
using CallCenterApi.Interface.Controllers.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CallCenterApi.Interface.Controllers
{
    [Authority]
    public class HistoryController : BaseController
    {
        /// <summary>
        /// 添加班组
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        //[Authority]
        public ActionResult Add()
        {
            string name = RequestString.GetFormString("name");
            string remark = RequestString.GetFormString("count");
            Model.T_Sys_History  dModel = new Model.T_Sys_History();
            dModel.F_UserID  = User.F_UserId ;
            dModel.F_Name  = name;
            dModel.F_Count  = remark;
            dModel.F_CreatTime  = DateTime .Now ;
            int n = new BLL.T_Sys_History().Add(dModel);
            if (n > 0)
                return Success("添加成功", n);
            else
                return Error("添加失败");
        }
        public ActionResult Delete(int type=0,int id=0)
        {
             if (type ==0)
             {
                if (id >0)
                {
                    bool n = new BLL.T_Sys_History().Delete(id);
                    if (n)
                        return Success("删除成功");
                    else
                        return Error("删除失败");
                }
                else
                {
                    return Error("请选择正确的历史记录");
                }
             }
             else
             {
                bool n = new BLL.T_Sys_History().DeleteList ("select " +
                    "F_ID from  T_Sys_History where F_UserID='"+User .F_UserId +"' ");
                if (n)
                    return Success("删除成功");
                else
                    return Error("删除失败");
            }
          
           
        }
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <returns></returns>
        //[Authority]
        public ActionResult GetList()
        {
            
            string name = RequestString.GetFormString("name");
            if (!string .IsNullOrEmpty (name))
            {
                string sql = "and F_Name='" + name + "'";
            }
           
            
            var modellist  = new BLL.T_Sys_History().GetModelList ("F_UserID='"+ User.F_UserId + "'");
           
            return Success("加载成功", modellist);
        }
    }
}