public async Task <IEnumerable <FolderDto> > GetFolderStructure() { var folderDtos = (await _folderRepository.ReadTopFolders()).Select(f => new FolderDto { Id = f.Id, Name = f.Name, Children = new List <FolderDto>(), Order = f.Order, ParentFolderId = f.ParentFolderId }).OrderBy(f => f.Order); var folders = (await _folderRepository.ReadFolders()).Where(f => folderDtos.All(fd => fd.Id != f.Id)); var structureDtos = new List <FolderDto>(); foreach (var folderDto in folderDtos) { structureDtos.Add(await ConvertChildFolders(folderDto, folders)); } return(structureDtos); }