public async Task DeleteDept(long deptId) { var dept = await _deptRepository.FetchAsync(x => x.ID == deptId); await _deptRepository.DeleteAsync(x => x.Pids.Contains($"[{dept.ID}]")); await _deptRepository.DeleteAsync(dept); }
public async Task <UserInfo> GetCurrentUserInfo() { var user = await _userRepository.FetchAsync(x => x.ID == _currentUser.ID); var dept = await _deptRepository.FetchAsync(x => x.ID == user.DeptId); UserInfo userContext = new UserInfo { Name = user.Name, Role = "admin" }; userContext.Profile = _mapper.Map <UserProfile>(user); userContext.Profile.Dept = dept.FullName; if (!string.IsNullOrWhiteSpace(user.RoleId)) { var roleIds = user.RoleId.Split(',', StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)); var roles = await _roleRepository.SelectAsync(x => roleIds.Contains(x.ID)); foreach (var role in roles) { userContext.Roles.Add(role.Tips); userContext.Profile.Roles.Add(role.Name); } var roleMenus = await _menuRepository.GetMenusByRoleIds(roleIds.ToArray(), true); if (roleMenus.Any()) { userContext.Permissions.AddRange(roleMenus.Select(x => x.Url).Distinct()); } } return(userContext); }