public ClientInfoEntity Update (ClientInfoEntity entity) { try { _clientinfoRepository.Update(entity); return entity; } catch (Exception e) { _log.Error(e,"数据库操作出错"); return null; } }
public bool Delete(ClientInfoEntity entity) { try { _clientinfoRepository.Delete(entity); return true; } catch (Exception e) { _log.Error(e,"数据库操作出错"); return false; } }
public HttpResponseMessage AddClientInfo([FromBody] ClientInfoEntity clientinfo) { if (clientinfo != null) { var entity = new ClientInfoEntity { Clientname = clientinfo.Clientname, Houses = clientinfo.Houses, Housetype = clientinfo.Housetype, Note = clientinfo.Note, Phone = clientinfo.Phone, Uptime = DateTime.Now, Addtime = DateTime.Now, Adduser = clientinfo.Adduser, Upuser = clientinfo.Upuser }; try { if (_clientInfoService.Create(entity) != null) { return PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!")); } } catch { return PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!")); } } return PageHelper.toJson(PageHelper.ReturnValue(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, "提交成功")); }