public override void DeleteItemByGroup(string groupID) { IList <VersionItem> versionsToDelete = VersionManager.GetAllVersions(groupID); foreach (VersionItem versToDelete in versionsToDelete) { Item item = NewsManager.GetItem(versToDelete.ItemId); NewsManager.DeleteItem(item); VersionManager.DeleteVersionItem(versToDelete); } }
public static int CountItems(IList <Item> items, string username) { if (items != null && items.Count > 0) { IList <VersionItem> vItems = new List <VersionItem>(); foreach (Item item1 in items) { VersionItem v = VersionManager.GetVersionByItemId(item1.Id); if (v != null) { VersionItem latest = new VersionItem(); IList <VersionItem> versions = VersionManager.GetAllVersions(v.GroupId); foreach (VersionItem version in versions) { if (VersionManager.IsLatestVersion(version.Id)) { latest = version; } } if (latest == null) { if (SecurityHelper.CanUserEdit(username, item1.Category.Id) || SecurityHelper.CanUserContribute(username, item1.Category.Id)) { vItems.Add(v); } } else { Item item2 = NewsManager.GetItem(latest.ItemId); if ((SecurityHelper.CanUserView(username, item2.Category.Id) && item2.ApprovalStatus.Name == "Published") || (SecurityHelper.CanUserContribute(username, item2.Category.Id) && item2.Owner.ToLower() == username.ToLower()) || (SecurityHelper.CanUserEdit(username, item2.Category.Id))) { if (item1.Category.Id == item2.Category.Id) { vItems.Add(v); } } } } } IEnumerable <VersionItem> disItems = vItems.Distinct(new KeyEqualityComparer <VersionItem>(x => x.GroupId)); return(disItems.Count()); } return(0); }