Exemple #1
0
        public void RenameFolder(string name, string newName, string path)
        {
            var folder = GetFolder(name, path);

            if (folder == null)
            {
                throw new Exception("folder does not exists!");
            }
            ValidateFolderNewNameInParentData(folder, newName);
            var oldName = folder.Name;
            var oldPath = $"{folder.Path}/{oldName}";
            var newPath = $"{folder.Path}/{newName}";

            _folderContentFolderRepository.CopyDirectory(newName, path, oldName, path);
            _folderContentPageService.MovePagesToNewLocation(folder, oldName, folder.Path, newName, folder.Path);
            folder.Name             = newName;
            folder.ModificationTime = $"{DateTime.Now:G}";
            UpdateFolder(folder);
            _folderContentFolderRepository.DeleteFolder(name, path);
            _folderContentFolderRepository.DeleteDirectory(oldName, path);
            var parent = GetParentFolder(folder);

            _folderContentPageService.RenameFolderContentInFolderPages(parent, name, newName, folder);
            UpdateFolderChildrenPath(folder, newPath, oldPath);
        }
        public void RenameFile(string oldName, string newName, string path)
        {
            var folderContentFile = GetFolderContentFile(oldName, path);

            if (folderContentFile == null)
            {
                throw new Exception("file does not exists!");
            }
            ValidateFileNameInParentData(folderContentFile, newName);
            folderContentFile.Name             = newName;
            folderContentFile.ModificationTime = $"{DateTime.Now:G}";
            UpdateFolderContentFile(folderContentFile);
            MoveFileToNewLocation(oldName, path, newName, path);
            var folder = _folderContentFolderService.GetParentFolder(folderContentFile);

            _folderContentPageService.RenameFolderContentInFolderPages(folder, oldName, newName, folderContentFile);
        }