Пример #1
0
        public async Task <PartialViewResult> InnerDropboxAccountContents(DropboxFolderGotoViewModel model)
        {
            var currUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            DropboxFolder        dropboxFileSystem;
            List <DropboxFolder> prevFolders;

            try
            {
                dropboxFileSystem = dropboxAccountService.GetFolder(currUser, model.FolderPath, model.FolderDepth);
            }
            catch (DropboxFolderEmptyException ex)
            {
                prevFolders = dropboxAccountService.GetPreviousFolders(currUser, model.FolderPath);
                DropboxFolderContentsViewModel dropboxContentsVar = new DropboxFolderContentsViewModel
                {
                    FolderPath      = model.FolderPath,
                    PreviousFolders = prevFolders
                };

                return(PartialView("_EmptyFolderPartial", dropboxContentsVar));
            }

            prevFolders = dropboxAccountService.GetPreviousFolders(currUser, model.FolderPath);
            DropboxFolderContentsViewModel dropboxContents = new DropboxFolderContentsViewModel
            {
                FolderPath      = dropboxFileSystem.Path,
                FolderName      = dropboxFileSystem.Name,
                DropboxFolders  = dropboxFileSystem.Folders,
                DropboxFiles    = dropboxFileSystem.Files,
                PreviousFolders = prevFolders
            };

            return(PartialView("_FolderPartial", dropboxContents));
        }
Пример #2
0
        public async Task <ActionResult> DropboxAccountContents()
        {
            DropboxFolderGotoViewModel model = new DropboxFolderGotoViewModel();

            if (TempData["folderContents"] != null)
            {
                model = TempData["folderContents"] as DropboxFolderGotoViewModel;
            }

            var currUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            DropboxFolder dropboxFileSystem;

            try
            {
                dropboxFileSystem = dropboxAccountService.GetFolder(currUser, model.FolderPath, model.FolderDepth);
            }
            catch (DropboxFolderEmptyException ex)
            {
                return(PartialView("_EmptyFolderPartial", new DropboxFolderContentsViewModel {
                    FolderPath = "/"
                }));
            }

            var prevFolders = dropboxAccountService.GetPreviousFolders(currUser, model.FolderPath);
            DropboxFolderContentsViewModel dropboxContents = new DropboxFolderContentsViewModel
            {
                FolderPath      = dropboxFileSystem.Path,
                FolderName      = dropboxFileSystem.Name,
                DropboxFolders  = dropboxFileSystem.Folders,
                DropboxFiles    = dropboxFileSystem.Files,
                PreviousFolders = prevFolders
            };

            return(View(dropboxContents));
        }