0

Within N2 CMS, is there a way to programmatically remove nodes from the trash?

Tron5000
  • 844
  • 11
  • 24

1 Answers1

0

I figured it out. In this example models of type TargetDetailModel are being permanently deleted from the N2 CMS trash.

var trash = new ItemList<TrashContainerItem>(N2.Find.RootItem.Children, new TypeFilter(typeof(TrashContainerItem))).FirstOrDefault();
if (trash != null)
{
  var detailToPermDelete = new ItemList<TargetDetailModel>(trash.Children, new TypeFilter(typeof(TargetDetailModel)));
  for (int permDeleteCount = 0; permDeleteCount < detailToPermDelete.Count; permDeleteCount++)
  {                            
    N2.Context.Current.Persister.Delete(detailToPermDelete.ElementAt(permDeleteCount));
  }
}
Tron5000
  • 844
  • 11
  • 24