/// <summary> /// 添加部门 /// </summary> /// <param name="org">The org.</param> /// <returns>System.Int32.</returns> /// <exception cref="System.Exception">未能找到该组织的父节点信息</exception> public Guid AddOrUpdate(Org org) { ChangeModuleCascade(org); if (org.Id == Guid.Empty) { _repository.Add(org); } else { //获取旧的的CascadeId var CascadeId = _repository.FindSingle(o => o.Id == org.Id).CascadeId; //根据CascadeId查询子部门 var orgs = _repository.Find(u => u.CascadeId.Contains(CascadeId) && u.Id != org.Id).OrderBy(u => u.CascadeId).ToList(); //更新操作 _repository.Update(org); //更新子部门的CascadeId foreach (var a in orgs) { ChangeModuleCascade(a); _repository.Update(a); } } return(org.Id); }
public Result Update(OrgDto dto) { try { var entity = dto.MapTo <OrgEntity>(); var rlt = UnitOfWorkService.Execute(() => _repo.Update(entity)); if (rlt) { return(new Result(true, "")); } return(new Result(false, "数据操作失败")); } catch (Exception ex) { Logger.Error("update org error:", ex); return(new Result(false, "内部服务器错误")); } }
/// <summary> /// 添加部门 /// </summary> /// <param name="org">The org.</param> /// <returns>System.Int32.</returns> /// <exception cref="System.Exception">未能找到该组织的父节点信息</exception> public int AddOrUpdate(Org org) { if (org.Id == 0) { ChangeModuleCascade(org); _repository.Add(org); } else { _repository.Update(org); } return(org.Id); }
/// <summary> /// 添加部门 /// </summary> /// <param name="org">The org.</param> /// <returns>System.Int32.</returns> /// <exception cref="System.Exception">未能找到该组织的父节点信息</exception> public Guid AddOrUpdate(Org org) { ChangeModuleCascade(org); if (org.Id == Guid.Empty) { _repository.Add(org); } else { _repository.Update(org); } return(org.Id); }