Exemplo n.º 1
0
        public async Task <IActionResult> CreateNewFolder(CreateNewFolderAddressModel model)
        {
            var folders = _folderLocator.SplitStrings(model.FolderNames);
            var folder  = await _folderLocator.LocateSiteAndFolder(model.AccessToken, model.SiteName, folders, model.RecursiveCreate);

            var conflict = await _dbContext
                           .Folders
                           .Where(t => t.ContextId == folder.Id)
                           .AnyAsync(t => t.FolderName == model.NewFolderName.ToLower());

            if (conflict)
            {
                return(this.Protocol(ErrorType.HasDoneAlready, $"Folder name: '{model.NewFolderName}' conflict!"));
            }
            var newFolder = new Folder
            {
                ContextId  = folder.Id,
                FolderName = model.NewFolderName.ToLower(),
            };

            _dbContext.Folders.Add(newFolder);
            await _dbContext.SaveChangesAsync();

            return(this.Protocol(ErrorType.Success, "Successfully created your new folder!"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> CreateNewFolder(CreateNewFolderAddressModel model)
        {
            var folders = _folderSplitter.SplitToFolders(model.FolderNames);
            var folder  = await _folderRepo.GetFolderAsOwner(model.AccessToken, model.SiteName, folders, model.RecursiveCreate);

            if (folder == null)
            {
                return(this.Protocol(ErrorType.NotFound, "Locate folder failed!"));
            }
            await _folderRepo.CreateNewFolder(folder.Id, model.NewFolderName);

            return(this.Protocol(ErrorType.Success, "Successfully created your new folder!"));
        }