Paria
07/30/2024, 8:51 AMMatthew Alexandros
07/30/2024, 9:19 AMMatthew Alexandros
07/30/2024, 11:06 AMpublic class LinkCounterHelper
{
private readonly IContentService _contentService;
private readonly IRelationService _relationService;
public LinkCounterHelper(IContentService contentService, IRelationService relationService)
{
_contentService = contentService;
_relationService = relationService;
}
public List<KeyValuePair<string, int>> GetSectionPageData()
{
var pageStats = new List<KeyValuePair<string, int>>();
var rootNode = _contentService.GetRootContent().FirstOrDefault();
var sectionNodes = _contentService.GetPagedChildren(rootNode.Id, 0, int.MaxValue, out _)
.Where(c => c.ContentType.Alias == "sectionHomePage" && !_contentService.GetPagedChildren(c.Id, 0, int.MaxValue, out _)
.Any(child => child.ContentType.Alias == "longStorySummaryPage"));
foreach (var node in sectionNodes)
{
var relationshipCount = _relationService.GetByChildId(node.Id).Count();
pageStats.Add(new KeyValuePair<string, int>(node.Name, relationshipCount));
}
return pageStats.OrderByDescending(x => x.Value).ToList();
}
}
Paria
07/31/2024, 1:20 PM