コード例 #1
0
 public static CMSPage Get(string url)
 {
     return(FullPageTable.FirstOrDefault(x => x.URL == url) ??
            (GetByType("MainPage").FirstOrDefault() ?? new CMSPage()
     {
         URL = "main"
     }));
 }
コード例 #2
0
        public static IEnumerable <CMSPage> GetByType(string typeName)
        {
            var type = new DB().PageTypes.FirstOrDefault(x => x.TypeName == typeName);

            return(type == null ? new List <CMSPage>()
            {
                new CMSPage()
                {
                    FullUrl = "/"
                }
            } : FullPageTable.Where(x => x.Type == type.ID).ToList());
        }
コード例 #3
0
        private void FillChildren(CMSPage cmsPage)
        {
            var childs = FullPageTable.Where(x => x.ParentID == cmsPage.ID).ToList();

            if (childs.Any())
            {
                _fullChildrenList.AddRange(childs.Select(x => x.ID));
            }
            foreach (var child in childs)
            {
                FillChildren(child);
            }
        }
コード例 #4
0
        public static string GetPageLinkByType(string typeName)
        {
            var type = new DB().PageTypes.FirstOrDefault(x => x.TypeName == typeName);

            return((type == null
                        ? new CMSPage()
            {
                FullUrl = "/"
            }
                        : (FullPageTable.FirstOrDefault(x => x.Type == type.ID) ?? new CMSPage()
            {
                FullUrl = "/"
            }))
                   .FullUrl);
        }
コード例 #5
0
        private void FillChildrenList(CMSPage cmsPage, ref List <int> list, int count)
        {
            var childs = FullPageTable.Where(x => x.ParentID == cmsPage.ID).ToList();

            if (childs.Any())
            {
                list.AddRange(childs.Select(x => x.ID));
            }
            if (list.Count >= count)
            {
                return;
            }
            foreach (var child in childs)
            {
                FillChildrenList(child, ref list, count);
            }
        }
コード例 #6
0
        public IEnumerable <CMSPage> GetHalfOfChildren(bool left, int limit = 100)
        {
            var all       = FullPageTable.Where(x => x.ParentID == ID).Take(limit).ToList();
            int leftCount = 0;
            int rem       = 0;

            leftCount = Math.DivRem(all.Count(), 2, out rem);
            if (rem > 0)
            {
                leftCount++;
            }
            if (left)
            {
                return(all.Take(leftCount));
            }
            return(all.Skip(leftCount));
        }
コード例 #7
0
 public static CMSPage Get(int ID)
 {
     return(FullPageTable.FirstOrDefault(x => x.ID == ID) ?? new CMSPage());
 }
コード例 #8
0
 public static IEnumerable <CMSPage> GetByType(int typeId)
 {
     return(FullPageTable.Where(x => x.Type == typeId).ToList());
 }
コード例 #9
0
 public IEnumerable <CMSPage> GetChildren()
 {
     return(FullPageTable.Where(x => x.ParentID == ID).ToList());
 }