예제 #1
0
        public async Task <IActionResult> CreateFolder(string root, RootCreateFolderViewModel model)
        {
            try
            {
                if (this.ModelState.IsValid)
                {
                    model.Root = root.ToFirstUpper();

                    bool created = await this.systemFilesService.CreateFolderAsync(model.FolderName, Path.Combine(this.GetRootDirectory(root), model.ParentFolderPath));

                    if (created)
                    {
                        string foldersRoute = string.IsNullOrEmpty(model.ParentFolderPath) ? string.Empty : "/" + model.ParentFolderPath.Replace("\\", "/");
                        return(this.LocalRedirect($"/admin/roots/{root}{foldersRoute}/{model.FolderName}"));
                    }

                    this.ModelState.AddModelError(nameof(RootCreateFolderViewModel.FolderName), $"Folder with name '{model.FolderName}' cannot be created.");
                }
            }
            catch (Exception)
            {
                this.ShowErrorNotification("Folder cannot be created.");
            }

            return(this.View(model));
        }
예제 #2
0
        public IActionResult CreateFolder(string root, string folders = "")
        {
            RootCreateFolderViewModel model = new RootCreateFolderViewModel();

            model.ParentFolderPath = folders;
            model.Root             = root.ToFirstUpper();

            return(this.View(model));
        }