Atomia.Provisioning.Modules.Folders.Commands.FoldersCommand.ExecuteModify C# (CSharp) Method

ExecuteModify() protected method

Executes the modify.
protected ExecuteModify ( ModuleService oldService, ModuleService newService ) : void
oldService ModuleService The old service.
newService ModuleService The new service.
return void
        protected override void ExecuteModify(ModuleService oldService, ModuleService newService)
        {
            //we rename folder to new name
            string rootFolder = this.resource["RootFolder"].ToString();
            if (rootFolder == "")
            {
                rootFolder = "c:\\ProvisioningModuleTestFolder\\";
            }

            if (rootFolder.Substring(rootFolder.Length - 1, 1) != "\\")
            {
                rootFolder += "\\";
            }

            string newFolderName = string.Empty;
            string oldFolderName = string.Empty;

            newFolderName = newService.Properties.Find(p => p.Name == "Name").Value;
            oldFolderName = oldService.Properties.Find(p => p.Name == "Name").Value;
            string newFolderFullPath = rootFolder + newFolderName;
            string oldFolderFullPath = rootFolder + oldFolderName;

            if (oldFolderName != newFolderName)
            {
                if (Directory.Exists(oldFolderFullPath))
                {
                    if (Directory.Exists(newFolderFullPath))
                    {
                        throw ExceptionHelper.GetModuleException("ID422010", null, null);
                    }
                    else
                    {
                        Directory.Move(oldFolderFullPath, newFolderFullPath);
                    }
                }
                else
                {
                    throw ExceptionHelper.GetModuleException("ID422007", null, null);
                }
            }
        }