using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HySoft.Common;

namespace HySoft.BaseCallCenter.Web.telmanage.ajax
{
    /// <summary>
    /// addcontact 的摘要说明
    /// </summary>
    public class addcontact : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //取得处事类型
            string action = CommonRequest.GetQueryString("action");
            switch (action)
            {
                case "addcontact":
                    context.Response.Write(AddContact(context));
                    break;
            }
        }
        private string AddContact(HttpContext context)
        {
            string res = "";
            string customerid = HttpUtility.UrlDecode(CommonRequest.GetQueryString("customerid"));
            string callinname = HttpUtility.UrlDecode(CommonRequest.GetQueryString("callinname"));
            string callinnumber = HttpUtility.UrlDecode(CommonRequest.GetQueryString("callinnumber"));
            Model.T_Cus_ContactPerson tccp = new Model.T_Cus_ContactPerson();
            if (customerid != "")
                tccp.F_CustomerId = Convert.ToInt32(customerid);
            if (callinname != "")
                tccp.F_Name = callinname;
            if (callinnumber != "")
            {
                tccp.F_Telephone = callinnumber;
                tccp.F_Mobile = callinnumber;
            }
            int b = new BLL.T_Cus_ContactPerson().Add(tccp);
            if (b > 0) res = "success";
            else res = "error";
            return res;
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}