public BrokerLeadClientEntity Update (BrokerLeadClientEntity entity)
		{
			try
            {
                _brokerleadclientRepository.Update(entity);
                return entity;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return null;
            }
		}
		public bool Delete(BrokerLeadClientEntity entity)
		{
			try
            {
                _brokerleadclientRepository.Delete(entity);
                return true;
            }
            catch (Exception e)
            {
				_log.Error(e,"数据库操作出错");
                return false;
            }
		}
        public HttpResponseMessage Add([FromBody] BrokerLeadClientModel brokerleadclient)
        {
            if (brokerleadclient.Adduser == 0) return PageHelper.toJson(PageHelper.ReturnValue(false, "经济人ID不能为空!"));
            if (brokerleadclient.Broker == 0) return PageHelper.toJson(PageHelper.ReturnValue(false, "经纪人ID不能为空!"));
            if (string.IsNullOrEmpty(brokerleadclient.Clientname)) return PageHelper.toJson(PageHelper.ReturnValue(false, "客户名不能为空"));
            if (string.IsNullOrEmpty(brokerleadclient.Phone)) return PageHelper.toJson(PageHelper.ReturnValue(false, "客户电话不能为空!"));

            //查询客户信息
            var sech = new BrokerLeadClientSearchCondition
            {
                ClientName = brokerleadclient.Clientname,
                Phone = brokerleadclient.Phone,
                Projectids = new[] { brokerleadclient.Projectid },
                DelFlag = EnumDelFlag.默认
            };

            var cmodel = _brokerleadclientService.GetBrokerLeadClientsByCondition(sech).FirstOrDefault();
            //检测客户是否存在于数据库
            if (cmodel == null)
            {
                //客户信息
                var client = new ClientInfoEntity
                {
                    Clientname = brokerleadclient.Clientname,
                    Phone = brokerleadclient.Phone.ToString(CultureInfo.InvariantCulture),
                    Housetype = brokerleadclient.HouseType,
                    Houses = brokerleadclient.Houses,
                    Note = brokerleadclient.Note,
                    Adduser = brokerleadclient.Broker,
                    Addtime = DateTime.Now,
                    Upuser = brokerleadclient.Broker,
                    Uptime = DateTime.Now
                };

                _clientInfoService.Create(client);
            }
            else
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "该客户正在被带客!"));
            }

            //查询客户信息
            var sech2 = new ClientInfoSearchCondition
            {
                Clientname = brokerleadclient.Clientname, 
                Phone = brokerleadclient.Phone.ToString(CultureInfo.InvariantCulture),
            };
            var cmodel2 = _clientInfoService.GetClientInfosByCondition(sech2).FirstOrDefault();
            if (cmodel2 == null)
            {
                return PageHelper.toJson(PageHelper.ReturnValue(false, "带客出错!"));
            }
            //查询经纪人信息
            var broker = _brokerService.GetBrokerByUserId(brokerleadclient.Adduser);
            //创建代客流程
            var model = new BrokerLeadClientEntity();
            model.Broker = _brokerService.GetBrokerById(brokerleadclient.Adduser);
            model.ClientInfo = cmodel2;
            model.ClientName = brokerleadclient.Clientname;
            model.Appointmenttime = Convert.ToDateTime(brokerleadclient.Appointmenttime);
            //model.Qq = Convert.ToInt32(brokerrecclient.Qq);
            model.Phone = brokerleadclient.Phone;       //客户电话
            model.Brokername = broker.Brokername;
            //model.BrokerLevel = broker.Level.Name;
            model.Broker = broker;
            model.Adduser = brokerleadclient.Adduser;
            model.Addtime = DateTime.Now;
            model.Upuser = brokerleadclient.Adduser;
            model.Uptime = DateTime.Now;
            //model.ProjectId = brokerleadclient.Id;
            model.ProjectId = brokerleadclient.Projectid;
            model.Projectname = brokerleadclient.Projectname;
            model.Status = EnumBLeadType.预约中;
            model.DelFlag = EnumDelFlag.默认;
            model.ComOrder = (int)EnumOrderType.带客订单;
            model.Details = brokerleadclient.Note;

            _brokerleadclientService.Create(model);

            return PageHelper.toJson(PageHelper.ReturnValue(true, "提交成功"));
        }