public IActionResult Update([FromBody] CustomerUpdateDto parm) { if (_customerService.Any(m => m.bm == parm.zzmc)) { return(toResponse(StatusCodeType.Error, $"客户组织名称{parm.zzmc} 已存在,不能重复!")); } var userSession = _tokenManager.GetSessionInfo(); _customerService.Update(m => m.ID == parm.ID, m => new uf_khxx() { zzmc = parm.zzmc, UpdateTime = DateTime.Now }); //删除联系人 string[] ids = parm.CustomerLinkList.Where(x => !string.IsNullOrEmpty(x.ID)).Select(x => x.ID).ToArray(); _customerlinkService.Delete(m => m.ParentUID == parm.ID && !ids.Contains(m.ID)); //修改联系人信息 foreach (var link in parm.CustomerLinkList) { //判断是否是新增 if (string.IsNullOrEmpty(link.ID)) { var customerlink = link.Adapt <uf_khxx_dt1>().ToCreate(_tokenManager.GetSessionInfo()); _customerlinkService.Add(customerlink); } else { _customerlinkService.Update(m => m.ID == link.ID, m => new uf_khxx_dt1() { lxr = link.lxr, bm = link.bm, zw = link.zw, zj = link.zj, sj = link.sj, yx = link.yx, bz = link.bz, UpdateTime = DateTime.Now }); } } return(toResponse("更新成功")); }
public IActionResult Delete(string id) { if (string.IsNullOrEmpty(id)) { return(toResponse(StatusCodeType.Error, "删除 Id 不能为空")); } var response = _customerlinkService.Delete(id); return(toResponse(response)); }