public List <TreeOutputDto> GetRoleList(string keyValue) { var roleList = roleRepository.IQueryable(c => c.isEnabled == true).ToList(); var accountRoleList = new List <AccountRoleEntity>(); if (!string.IsNullOrEmpty(keyValue)) { accountRoleList = accountRoleApp.FindList(keyValue).ToList(); } var treeList = new List <TreeOutputDto>(); foreach (RoleEntity item in roleList) { var tree = new TreeOutputDto(); tree.id = item.roleGuid; tree.text = item.roleName; tree.value = string.Empty; tree.parentId = "0"; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = accountRoleList.Count(t => t.roleInfoGuid == item.roleGuid); tree.hasChildren = false; tree.img = ""; treeList.Add(tree); } return(treeList); }
public void SubmitForm(TeamMembersEntity entity, string keyValue) { if (string.IsNullOrEmpty(entity.membersGuid)) { var count = FindList(c => c.isEnabled && c.teamInfoGuid == keyValue).Count(); if (count >= 5) { throw new Exception("每个团队中团队成员不能超过4个!!!"); } var account = entity.membersName.Split('&'); entity.Create(); entity.accountInfoGuid = account[0]; entity.membersName = account[1]; entity.teamInfoGuid = keyValue; entity.membersFunction = "组员"; teamMembersRepository.Insert(entity); } else { var lenderEntity = FindList(c => c.isEnabled && c.membersFunction == "组长" && c.teamInfoGuid == keyValue).FirstOrDefault(); var roleEntity = roleApp.FindEntity(c => c.isEnabled && c.roleName.Contains("组长")); entity.membersFunction = "组长"; //该团队对没有组长 if (lenderEntity == null) { var menbersGuid = entity.membersGuid; entity.Modify(menbersGuid); entity.teamInfoGuid = keyValue; var accountRoleEntity = new AccountRoleEntity() { accountInfoGuid = entity.accountInfoGuid, roleInfoGuid = roleEntity.roleGuid }; accountRoleEntity.Create(); accountRoleApp.SubmitForm(accountRoleEntity, ""); teamMembersRepository.Update(entity); } //该团队对有组长 if (lenderEntity != null && !lenderEntity.membersGuid.Equals(entity.membersGuid)) { var accountRoleEntityList = accountRoleApp.FindList(lenderEntity.accountInfoGuid); var accountRoleEntity = accountRoleEntityList.Where(c => c.roleInfoGuid == roleEntity.roleGuid).FirstOrDefault(); accountRoleEntity.accountInfoGuid = entity.accountInfoGuid; accountRoleApp.SubmitForm(accountRoleEntity, accountRoleEntity.accountRoleGuid); lenderEntity.membersFunction = "组员"; lenderEntity.Modify(lenderEntity.membersGuid); entity.Modify(entity.membersGuid); using (var db = teamMembersRepository.BeginTrans()) { db.Update(lenderEntity); db.Update(entity); db.Commit(); } } } }