public IActionResult GetFolder(Guid folderId) { string folderName = "root"; if (folderId != Guid.Empty) { var currentFolder = _folderRepo.Where(f => f.Id == folderId).FirstOrDefault(); if (currentFolder == null) { return(BadRequest("Папка не найдена!")); } folderId = currentFolder.Id; folderName = currentFolder.FolderName; } if (folderId != Guid.Empty && !UserHasRole(folderId, AccessLevel.Read)) { return(BadRequest("Не достаточно уровня прав доступа!")); } var childFolders = _folderService.GetSubFolders(folderId, UserContext.Id); var response = new GetFoldersResponse { Folder = new FolderDescription { FolderId = folderId, FolderName = folderName, Folders = childFolders.Select(f => new ChildFolder { FolderName = f.FolderName, FolderId = f.Id }).ToList(), FullPath = _folderService.GetFullPath(folderId), Files = _folderService.GetFiles(folderId), Owners = _db.Set <UsersFolders>().Where(uf => uf.FolderId == folderId && uf.AccessLevel == AccessLevel.Owner).Select(uf => _db.Users.First(u => u.Id == uf.UserId).Username).ToList() } }; return(Ok(response)); }