public JsonResult DeleteFolder(string id, bool deleteAllPages) { BaseService.CheckLoginAndLicense(); CmsPageFolder folder = GetFolder(id, null); CmsPageFolder ParentFolder; if (folder.GetPages().Count > 0 || folder.GetSubFolders().Count > 0) { if (!deleteAllPages) { return(JsonResult.CreateResult(false, "Wilt u deze map inclusief alle subitems van deze map verwijderen?<br />")); } else { ParentFolder = folder.ParentFolder; DeleteFolderRecursief(folder); } } else { ParentFolder = folder.ParentFolder; folder.Delete(); } string ParentFolderId = (ParentFolder == null) ? null : ParentFolder.ID.ToString(); return(JsonResult.CreateResult(true, GetFoldersAndPages(ParentFolderId, "", "", ""))); }
private static void DeleteFolderRecursief(CmsPageFolder parentFolder) { foreach (CmsPageFolder folder in parentFolder.GetSubFolders()) { DeleteFolderRecursief(folder); } foreach (CmsPage page in parentFolder.GetPages()) { page.Delete(); } parentFolder.Delete(); }