Beispiel #1
0
        private IEnumerable <PageModel> GetChildren(Data.Page p, int depth)
        {
            var firstLevel = new[] { p }.ToList();
            var levels = EnumerableEx.Generate(new { pages = firstLevel, depth = Math.Max(4, depth) }, x => x.depth >= 0 && x.pages.Any(),
                                               x => new { pages = PagesService.GetChildPages(x.pages).ToList(), depth = x.depth - 1 },
                                               x => x.pages)
                         .ToList();

            return(MergeChildPages(p, levels.Skip(1)));
        }
Beispiel #2
0
 public Maybe <PageModel> PageModel(string url)
 {
     return(from p in PagesService.GetPage(url, Auth.CurrentActor.IsAdmin).MaybeDefined()
            from parents in PagesService.GetParentPages(p)
            from topParent in parents.Where(pr => pr.Url != null && pr.Url != "").OrderBy(pr => pr.Url.Length).FirstOrDefault() ?? p
            select new PageModel {
         Page = p,
         TopParent = topParent,
         AllowEdit = Auth.CurrentActor.IsAdmin,
         ChildPages = GetChildren(topParent, parents.Count())
     });
 }