Пример #1
0
        public List <ExtendedSelectListItem> GetSitemapListURLByContent(int domainID, string selectedUrl)
        {
            tbl_ContentType type = ContentTypeRepository.GetByType(ContentType.Content);

            if (type == null)
            {
                return(null);
            }

            List <ExtendedSelectListItem> sections = new List <ExtendedSelectListItem>();

            foreach (var section in SitemapRepository.GetByContentTypeID(type.ContentTypeID, domainID).OrderBy(c => c.SM_OrderBy))
            {
                var parent = sections.FirstOrDefault(s => s.ID == section.SM_ParentID);
                if (sections.Contains(parent))
                {
                    string appendix = String.Empty;
                    int    level    = parent.Level;
                    while (level > 0)
                    {
                        appendix += "&nbsp;&nbsp;"; level--;
                    }

                    sections.Insert(sections.IndexOf(parent) + 1, new ExtendedSelectListItem
                    {
                        Text     = appendix + section.SM_Name,
                        Value    = section.SM_URL,
                        Selected = section.SM_URL == selectedUrl,
                        Level    = parent.Level + 1,
                        ID       = section.SiteMapID
                    });
                }
                else
                {
                    sections.Add(new ExtendedSelectListItem
                    {
                        Text     = section.SM_Name,
                        Value    = section.SM_URL,
                        Selected = section.SM_URL == selectedUrl,
                        Level    = 1,
                        ID       = section.SiteMapID
                    });
                }
            }
            return(sections);
        }
Пример #2
0
        public List <tbl_Content> GetContentByContentType(ContentType contentType, int domainID, int top)
        {
            tbl_ContentType type = ContentTypeRepository.GetByType(contentType);

            if (type == null)
            {
                return(null);
            }

            var sitemaps = SitemapRepository.GetByContentTypeID(type.ContentTypeID, domainID)
                           .Where(c => (contentType != ContentType.Blog || (c.SM_Live && (c.SM_PublishDate == null || c.SM_PublishDate <= DateTime.Now))))
                           .OrderByDescending(b => b.SM_Date).Take(top);

            if (sitemaps == null || sitemaps.Count() == 0)
            {
                return(null);
            }

            return(sitemaps.Select(s => s.tbl_Content.Where(c => c.C_Approved && !c.C_Deleted).OrderByDescending(c => c.C_ModificationDate).FirstOrDefault()).Where(b => b != null).ToList());
        }
Пример #3
0
        public List <ExtendedSelectListItem> GetSitemapListByContent(int domainID, int selectedSitemapID)
        {
            tbl_ContentType type = ContentTypeRepository.GetByType(ContentType.Content);

            if (type == null)
            {
                return(null);
            }

            List <ExtendedSelectListItem> sections = new List <ExtendedSelectListItem>();

            foreach (var section in SitemapRepository.GetByContentTypeID(type.ContentTypeID, domainID).OrderBy(c => c.SM_OrderBy))
            {
                var parent = sections.FirstOrDefault(s => s.Value == section.SM_ParentID.ToString());
                if (sections.Contains(parent))
                {
                    sections.Insert(sections.IndexOf(parent) + 1, new ExtendedSelectListItem
                    {
                        Text     = section.SM_Name,
                        Value    = section.SiteMapID.ToString(),
                        Selected = section.SiteMapID == selectedSitemapID,
                        Level    = parent != null ? parent.Level + 1 : 1
                    });
                }
                else
                {
                    sections.Add(new ExtendedSelectListItem
                    {
                        Text     = section.SM_Name,
                        Value    = section.SiteMapID.ToString(),
                        Selected = section.SiteMapID == selectedSitemapID,
                        Level    = parent != null ? parent.Level + 1 : 1
                    });
                }
            }
            return(sections);
        }
Пример #4
0
        public List <tbl_SiteMap> GetSitemapByContentType(ContentType contentType, int domainID)
        {
            tbl_ContentType type = ContentTypeRepository.GetByType(contentType);

            if (type == null)
            {
                return(new List <tbl_SiteMap>());
            }

            var sitemaps = SitemapRepository.GetByContentTypeID(type.ContentTypeID, domainID).ToList();

            switch (contentType)
            {
            case ContentType.Product:
                sitemaps = sitemaps.Where(s => s.tbl_Products != null).ToList();
                break;

            case ContentType.Category:
                sitemaps = sitemaps.Where(s => s.tbl_ProdCategories != null).ToList();
                break;
            }

            return(sitemaps);
        }