private OrganizationalStructureDto MapUsersToOrganizationalStructureDto(OrganizationalStructureUserDto user, IList <OrganizationalStructureUserDto> userList) { return(new OrganizationalStructureDto { FullName = user.FirstName + " " + user.LastName, PictureId = user.PictureId, Children = GetChildren(userList, user) }); }
private IEnumerable <OrganizationalStructureDto> GetChildren(IList <OrganizationalStructureUserDto> userList, OrganizationalStructureUserDto head) { var childrenList = new List <OrganizationalStructureDto>(); userList .Where(user => user.ManagerId == head.Id) .ForEach(user => childrenList.Add(MapUsersToOrganizationalStructureDto(user, userList))); return(childrenList); }