GetIDByType() public static method

public static GetIDByType ( PageType contentType ) : System.Guid
contentType PageType
return System.Guid
        internal static IQueryable <vw_carrot_Content> GetContentByCategoryIDs(CarrotCMSDataContext ctx, Guid siteID, bool bActiveOnly, List <Guid> lstCategoryGUIDs, List <string> lstCategorySlugs)
        {
            if (lstCategoryGUIDs == null)
            {
                lstCategoryGUIDs = new List <Guid>();
            }
            if (lstCategorySlugs == null)
            {
                lstCategorySlugs = new List <string>();
            }

            return(from ct in ctx.vw_carrot_Contents
                   where ct.SiteID == siteID &&
                   ((from m in ctx.carrot_CategoryContentMappings
                     join cc in ctx.carrot_ContentCategories on m.ContentCategoryID equals cc.ContentCategoryID
                     where cc.SiteID == siteID &&
                     lstCategorySlugs.Contains(cc.CategorySlug)
                     select m.Root_ContentID).Contains(ct.Root_ContentID) ||
                    (from m in ctx.carrot_CategoryContentMappings
                     where lstCategoryGUIDs.Contains(m.ContentCategoryID)
                     select m.Root_ContentID).Contains(ct.Root_ContentID)) &&
                   ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry) &&
                   (ct.PageActive == true || bActiveOnly == false) &&
                   (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
                   (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false) &&
                   ct.IsLatestVersion == true
                   select ct);
        }
 internal static IQueryable <carrot_RootContent> GetContentAllRootTbl(CarrotCMSDataContext ctx, Guid siteID)
 {
     return(from ct in ctx.carrot_RootContents
            where ct.SiteID == siteID
            where ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.ContentEntry)
            select ct);
 }
Example #3
0
        private void PerformCommonSaveRoot(SiteData pageSite, carrot_RootContent rc)
        {
            rc.Root_ContentID = this.Root_ContentID;
            rc.PageActive     = true;
            rc.BlockIndex     = false;
            rc.ShowInSiteMap  = true;

            rc.SiteID        = this.SiteID;
            rc.ContentTypeID = ContentPageType.GetIDByType(this.ContentType);

            rc.CreateDate = DateTime.UtcNow;
            if (this.CreateUserId != Guid.Empty)
            {
                rc.CreateUserId = this.CreateUserId;
            }
            else
            {
                rc.CreateUserId = SecurityData.CurrentUserGuid;
            }
            rc.GoLiveDate = pageSite.ConvertSiteTimeToUTC(this.GoLiveDate);
            rc.RetireDate = pageSite.ConvertSiteTimeToUTC(this.RetireDate);

            if (this.CreateDate.Year > 1950)
            {
                rc.CreateDate = pageSite.ConvertSiteTimeToUTC(this.CreateDate);
            }
        }
        public void FixOrphanPages(Guid siteID)
        {
            List <SiteMapOrder> lstContent = CannedQueries.GetAllContentList(db, siteID).Select(ct => new SiteMapOrder(ct)).ToList();
            List <Guid>         lstIDs     = lstContent.Select(x => x.Root_ContentID).ToList();

            lstContent.RemoveAll(x => x.Parent_ContentID == null);
            lstContent.RemoveAll(x => lstIDs.Contains(x.Parent_ContentID.Value));

            lstIDs = lstContent.Select(x => x.Root_ContentID).ToList();

            IQueryable <carrot_Content> querySite = (from c in db.carrot_Contents
                                                     where c.IsLatestVersion == true &&
                                                     c.Parent_ContentID != null &&
                                                     lstIDs.Contains(c.Root_ContentID)
                                                     select c);

            db.carrot_Contents.BatchUpdate(querySite, p => new carrot_Content {
                Parent_ContentID = null
            });

            IQueryable <carrot_Content> querySite2 = (from c in db.carrot_Contents
                                                      join rc in db.carrot_RootContents on c.Root_ContentID equals rc.Root_ContentID
                                                      where c.IsLatestVersion == true &&
                                                      c.Parent_ContentID != null &&
                                                      rc.SiteID == siteID &&
                                                      rc.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry)
                                                      select c);

            db.carrot_Contents.BatchUpdate(querySite2, p => new carrot_Content {
                Parent_ContentID = null
            });

            db.SubmitChanges();
        }
 internal static IQueryable <vw_carrot_Comment> GetSiteContentCommentsByPostType(CarrotCMSDataContext ctx, Guid siteID, ContentPageType.PageType contentEntry)
 {
     return(from r in ctx.vw_carrot_Comments
            orderby r.CreateDate descending
            where r.SiteID == siteID &&
            r.ContentTypeID == ContentPageType.GetIDByType(contentEntry)
            select r);
 }
 internal static IQueryable <vw_carrot_Content> GetAllBlogList(CarrotCMSDataContext ctx, Guid siteID)
 {
     return(from ct in ctx.vw_carrot_Contents
            orderby ct.NavOrder, ct.NavMenuText
            where ct.SiteID == siteID &&
            ct.IsLatestVersion == true &&
            ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry)
            select ct);
 }
 internal static IQueryable <carrot_Content> GetContentAllContentTbl(CarrotCMSDataContext ctx, Guid siteID)
 {
     return(from ct in ctx.carrot_RootContents
            join c in ctx.carrot_Contents on ct.Root_ContentID equals c.Root_ContentID
            where ct.SiteID == siteID
            where c.IsLatestVersion == true &&
            ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.ContentEntry)
            select c);
 }
 internal static IQueryable <vw_carrot_Comment> GetSiteContentCommentsByPostType(CarrotCMSDataContext ctx, Guid siteID, ContentPageType.PageType contentEntry, bool?approved, bool?spam)
 {
     return(from r in ctx.vw_carrot_Comments
            orderby r.CreateDate descending
            where r.SiteID == siteID &&
            (spam == null || r.IsSpam == spam) &&
            (approved == null || r.IsApproved == approved) &&
            r.ContentTypeID == ContentPageType.GetIDByType(contentEntry)
            select r);
 }
        internal static Dictionary <string, float> GetTemplateCounts(CarrotCMSDataContext ctx, Guid siteID, ContentPageType.PageType pageType)
        {
            Guid contentTypeID = ContentPageType.GetIDByType(pageType);

            return((from ct in ctx.vw_carrot_Contents.Where(c => c.SiteID == siteID && c.ContentTypeID == contentTypeID && c.IsLatestVersion == true)
                    group ct by ct.TemplateFile.ToLower() into grp
                    orderby grp.Count() descending
                    select new KeyValuePair <string, float>(grp.Key.ToLower(), (float)grp.Count()))
                   .ToDictionary(t => t.Key, t => t.Value));
        }
 internal static IQueryable <vw_carrot_Content> GetLatestContentList(CarrotCMSDataContext ctx, Guid siteID, bool bActiveOnly)
 {
     return(from ct in ctx.vw_carrot_Contents
            orderby ct.NavOrder, ct.NavMenuText
            where ct.SiteID == siteID &&
            ct.IsLatestVersion == true &&
            ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.ContentEntry) &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false)
            select ct);
 }
 internal static IQueryable <vw_carrot_Content> GetLatestBlogListDateRange(CarrotCMSDataContext ctx, Guid siteID, DateTime dateBegin, DateTime dateEnd, bool bActiveOnly)
 {
     return(from ct in ctx.vw_carrot_Contents
            where ct.SiteID == siteID &&
            ct.IsLatestVersion == true &&
            ct.GoLiveDate >= dateBegin &&
            ct.GoLiveDate <= dateEnd &&
            ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry) &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false)
            select ct);
 }
 internal static IQueryable <vw_carrot_Content> GetContentByCategoryURL(CarrotCMSDataContext ctx, Guid siteID, bool bActiveOnly, string sCatURL)
 {
     return(from c in ctx.vw_carrot_CategoryURLs
            join m in ctx.carrot_CategoryContentMappings on c.ContentCategoryID equals m.ContentCategoryID
            join ct in ctx.vw_carrot_Contents on m.Root_ContentID equals ct.Root_ContentID
            where c.SiteID == siteID &&
            ct.SiteID == siteID &&
            c.CategoryUrl.ToLower() == sCatURL.ToLower() &&
            ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry) &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false) &&
            ct.IsLatestVersion == true
            select ct);
 }
 internal static IQueryable <vw_carrot_Content> GetContentByUserURL(CarrotCMSDataContext ctx, Guid siteID, bool bActiveOnly, string sUserURL)
 {
     return(from ed in ctx.vw_carrot_EditorURLs
            join ct in ctx.vw_carrot_Contents on ed.SiteID equals ct.SiteID
            where ed.SiteID == siteID &&
            ct.SiteID == siteID &&
            ed.UserUrl.ToLower() == sUserURL.ToLower() &&
            ct.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry) &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false) &&
            ct.IsLatestVersion == true &&
            ((ed.UserId == ct.EditUserId && ct.CreditUserId == null) ||
             (ed.UserId == ct.CreditUserId && ct.CreditUserId != null))
            select ct);
 }
        internal static IQueryable <vw_carrot_Content> GetContentByStatusAndDateRange(CarrotCMSDataContext ctx, Guid siteID, ContentPageType.PageType pageType,
                                                                                      DateTime dateBegin, DateTime dateEnd, bool?bActive, bool?bSiteMap, bool?bSiteNav, bool?bBlock)
        {
            Guid gContent      = ContentPageType.GetIDByType(ContentPageType.PageType.ContentEntry);
            Guid gBlog         = ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry);
            Guid contentTypeID = ContentPageType.GetIDByType(pageType);

            return(from ct in ctx.vw_carrot_Contents
                   orderby ct.ContentTypeValue, ct.NavMenuText
                   where ct.SiteID == siteID &&
                   ct.IsLatestVersion == true &&
                   ct.GoLiveDate >= dateBegin &&
                   ct.GoLiveDate <= dateEnd &&
                   (ct.ContentTypeID == contentTypeID || pageType == ContentPageType.PageType.Unknown) &&
                   (ct.PageActive == Convert.ToBoolean(bActive) || bActive == null) &&
                   (ct.BlockIndex == Convert.ToBoolean(bBlock) || bBlock == null) &&
                   ((ct.ShowInSiteMap == Convert.ToBoolean(bSiteMap) && ct.ContentTypeID == gContent) || bSiteMap == null) &&
                   ((ct.ShowInSiteNav == Convert.ToBoolean(bSiteNav) && ct.ContentTypeID == gContent) || bSiteNav == null)
                   select ct);
        }
Example #15
0
        public TimeZoneContent(Guid siteID)
        {
            // use C# libraries for timezones rather than pass in offset as some dates are +/- an hour off because of DST

            this.SiteID = siteID;

            this.ContentLocalDates = new List <ContentLocalTime>();

            this.BlogPostUrls = new List <BlogPostPageUrl>();

            SiteData site = SiteData.GetSiteFromCache(siteID);

            List <carrot_RootContent> queryAllContent = null;

            using (CarrotCMSDataContext db = CarrotCMSDataContext.GetDataContext()) {
                queryAllContent = CannedQueries.GetAllRootTbl(db, siteID).ToList();
            }

            var allContentDates = (from p in queryAllContent
                                   select p.GoLiveDate).Distinct().ToList();

            var blogDateList = (from p in queryAllContent
                                where p.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry)
                                select p.GoLiveDate).Distinct().ToList();

            this.ContentLocalDates = (from d in allContentDates
                                      select new ContentLocalTime()
            {
                GoLiveDate = d,
                GoLiveDateLocal = site.ConvertUTCToSiteTime(d)
            }).ToList();

            this.BlogPostUrls = (from bd in blogDateList
                                 join ld in this.ContentLocalDates on bd equals ld.GoLiveDate
                                 select new BlogPostPageUrl()
            {
                GoLiveDate = ld.GoLiveDate,
                PostPrefix = CleanPostPrefix(ContentPageHelper.CreateFileNameFromSlug(siteID, ld.GoLiveDateLocal, string.Empty)),
                GoLiveDateLocal = ld.GoLiveDateLocal
            }).ToList();
        }
Example #16
0
        public TimeZoneContent(Guid siteID)
        {
            // use C# libraries for timezones rather than pass in offset as some dates are +/- an hour off because of DST

            this.SiteID = siteID;

            this.ContentLocalDates = new List <ContentLocalTime>();

            this.BlogPostUrls = new List <BlogPostPageUrl>();

            SiteData site = SiteData.GetSiteFromCache(siteID);

            List <carrot_RootContent> queryAllContent = null;

            using (CarrotCMSDataContext db = CarrotCMSDataContext.Create()) {
                queryAllContent = CannedQueries.GetAllRootTbl(db, siteID).ToList();
            }

            this.ContentLocalDates = (from p in queryAllContent
                                      select new ContentLocalTime {
                Root_ContentID = p.Root_ContentID,
                ContentTypeID = p.ContentTypeID,
                GoLiveDate = p.GoLiveDate,
                PageSlug = p.PageSlug,
                FileName = p.FileName,
                GoLiveDateLocal = site.ConvertUTCToSiteTime(p.GoLiveDate)
            }).ToList();

            IEnumerable <ContentLocalTime> queryBlog = (from c in this.ContentLocalDates
                                                        where c.ContentTypeID == ContentPageType.GetIDByType(ContentPageType.PageType.BlogEntry)
                                                        select c);

            this.BlogPostUrls = (from p in queryBlog
                                 select new BlogPostPageUrl {
                Root_ContentID = p.Root_ContentID,
                GoLiveDateLocal = p.GoLiveDateLocal,
                FileName = ContentPageHelper.CreateFileNameFromSlug(siteID, p.GoLiveDateLocal, p.PageSlug)
            }).ToList();
        }