예제 #1
0
        public async Task <FolderViewModel> GetFolderAsync(string groupSlug, Guid?folderId, CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(groupSlug))
            {
                throw new ArgumentNullException(nameof(groupSlug));
            }

            if (!folderId.HasValue)
            {
                return(new FolderViewModel
                {
                    Slug = groupSlug,
                    Folder = null,
                    ChildFolders = await _folderRepository.GetRootFoldersForGroupAsync(groupSlug : groupSlug, cancellationToken : cancellationToken),
                    Files = new List <FileReadViewModel>()
                });
            }
            else
            {
                return(new FolderViewModel
                {
                    Slug = groupSlug,
                    Folder = await _folderRepository.GetFolderAsync(folderId.Value, cancellationToken),
                    ChildFolders = await _folderRepository.GetChildFoldersForFolderAsync(parentFolderId : folderId.Value, cancellationToken : cancellationToken),
                    Files = (await _fileRepository.GetFilesAsync(folderId.Value, cancellationToken: cancellationToken)).ToList()
                });
            }
        }