GetSiteFromCache() public static method

public static GetSiteFromCache ( System.Guid siteID ) : SiteData
siteID System.Guid
return SiteData
Beispiel #1
0
        internal SiteNav(vw_carrot_Content c)
        {
            if (c != null)
            {
                SiteData site = SiteData.GetSiteFromCache(c.SiteID);

                this.Root_ContentID   = c.Root_ContentID;
                this.SiteID           = c.SiteID;
                this.FileName         = c.FileName;
                this.Thumbnail        = c.PageThumbnail;
                this.ShowInSiteMap    = c.ShowInSiteMap;
                this.BlockIndex       = c.BlockIndex;
                this.PageActive       = c.PageActive;
                this.CreateDate       = site.ConvertUTCToSiteTime(c.CreateDate);
                this.GoLiveDate       = site.ConvertUTCToSiteTime(c.GoLiveDate);
                this.RetireDate       = site.ConvertUTCToSiteTime(c.RetireDate);
                this.EditDate         = site.ConvertUTCToSiteTime(c.EditDate);
                this.EditUserId       = c.EditUserId;
                this.CreditUserId     = c.CreditUserId;
                this.ShowInSiteNav    = c.ShowInSiteNav;
                this.CreateUserId     = c.CreateUserId;
                this.ContentType      = ContentPageType.GetTypeByID(c.ContentTypeID);
                this.ContentID        = c.ContentID;
                this.Parent_ContentID = c.Parent_ContentID;
                this.TitleBar         = c.TitleBar;
                this.NavMenuText      = c.NavMenuText;
                this.PageHead         = c.PageHead;
                this.PageText         = c.PageText;
                this.NavOrder         = c.NavOrder;
                this.TemplateFile     = c.TemplateFile;
            }
        }
Beispiel #2
0
        public EditHistory(vw_carrot_EditHistory p)
        {
            if (p != null)
            {
                SiteData site = SiteData.GetSiteFromCache(p.SiteID);

                this.SiteID           = p.SiteID;
                this.ContentID        = p.ContentID;
                this.Root_ContentID   = p.Root_ContentID;
                this.IsLatestVersion  = p.IsLatestVersion;
                this.TitleBar         = p.TitleBar;
                this.NavMenuText      = p.NavMenuText;
                this.PageHead         = p.PageHead;
                this.EditUserId       = p.EditUserId;
                this.EditDate         = site.ConvertUTCToSiteTime(p.EditDate);
                this.FileName         = p.FileName;
                this.ContentTypeID    = p.ContentTypeID;
                this.ContentTypeValue = p.ContentTypeValue;
                this.PageActive       = p.PageActive;
                this.GoLiveDate       = site.ConvertUTCToSiteTime(p.GoLiveDate);
                this.RetireDate       = site.ConvertUTCToSiteTime(p.RetireDate);
                this.CreateDate       = site.ConvertUTCToSiteTime(p.CreateDate);
                this.EditUserName     = p.EditUserName;
                this.EditEmail        = p.EditEmail;
                this.CreateUserName   = p.CreateUserName;
                this.CreateEmail      = p.CreateEmail;
            }
        }
        internal ContentSnippet(vw_carrot_ContentSnippet c)
        {
            if (c != null)
            {
                SiteData site = SiteData.GetSiteFromCache(c.SiteID);

                this.Root_ContentSnippetID = c.Root_ContentSnippetID;
                this.SiteID               = c.SiteID;
                this.ContentSnippetID     = c.ContentSnippetID;
                this.ContentSnippetName   = c.ContentSnippetName;
                this.ContentSnippetSlug   = c.ContentSnippetSlug;
                this.ContentSnippetActive = c.ContentSnippetActive;
                this.IsLatestVersion      = c.IsLatestVersion;
                this.ContentBody          = c.ContentBody;

                this.CreateUserId = c.CreateUserId;
                this.CreateDate   = site.ConvertUTCToSiteTime(c.CreateDate);
                this.EditUserId   = c.EditUserId;
                this.EditDate     = site.ConvertUTCToSiteTime(c.EditDate);
                this.GoLiveDate   = site.ConvertUTCToSiteTime(c.GoLiveDate);
                this.RetireDate   = site.ConvertUTCToSiteTime(c.RetireDate);

                this.Heartbeat_UserId = c.Heartbeat_UserId;
                this.EditHeartbeat    = c.EditHeartbeat;

                this.VersionCount = c.VersionCount;
            }
        }
        internal SiteMapOrder(vw_carrot_Content c)
        {
            if (c != null)
            {
                SiteData site = SiteData.GetSiteFromCache(c.SiteID);

                this.SiteID           = c.SiteID;
                this.Root_ContentID   = c.Root_ContentID;
                this.PageActive       = c.PageActive;
                this.Parent_ContentID = c.Parent_ContentID;
                this.NavMenuText      = c.NavMenuText;
                this.FileName         = c.FileName;
                this.NavOrder         = c.NavOrder;

                if (this.Parent_ContentID.HasValue)
                {
                    this.NavLevel = 0;
                }
                else
                {
                    this.NavLevel = 10;
                }

                this.ContentType = ContentPageType.GetTypeByID(c.ContentTypeID);
                this.CreateDate  = site.ConvertUTCToSiteTime(c.CreateDate);
                this.GoLiveDate  = site.ConvertUTCToSiteTime(c.GoLiveDate);
                this.RetireDate  = site.ConvertUTCToSiteTime(c.RetireDate);
            }
        }
Beispiel #5
0
        private void SetVals(vw_carrot_Widget ww)
        {
            if (ww != null)
            {
                SiteData site = SiteData.GetSiteFromCache(ww.SiteID);

                this.IsWidgetPendingDelete = false;
                this.IsPendingChange       = false;
                this.WidgetDataID          = ww.WidgetDataID;

                this.EditDate   = site.ConvertUTCToSiteTime(ww.EditDate);
                this.GoLiveDate = site.ConvertUTCToSiteTime(ww.GoLiveDate);
                this.RetireDate = site.ConvertUTCToSiteTime(ww.RetireDate);

                this.IsLatestVersion   = ww.IsLatestVersion;
                this.ControlProperties = ww.ControlProperties;

                this.Root_WidgetID   = ww.Root_WidgetID;
                this.Root_ContentID  = ww.Root_ContentID;
                this.WidgetOrder     = ww.WidgetOrder;
                this.ControlPath     = ww.ControlPath;
                this.PlaceholderName = ww.PlaceholderName;
                this.IsWidgetActive  = ww.WidgetActive;
            }
        }
Beispiel #6
0
        public string SendTrackback(Uri targetURL, SiteNav pageNav)
        {
            this.DestinationUrl = targetURL;
            this.SourcePage     = pageNav;
            this.BlogSite       = SiteData.GetSiteFromCache(this.SourcePage.SiteID);

            return(SendTrackback());
        }
Beispiel #7
0
        public string SendTrackback(string sourceURL, Guid siteID, string sTgtURL)
        {
            this.DestinationUrl = new Uri(sTgtURL);
            this.BlogSite       = SiteData.GetSiteFromCache(siteID);

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                this.SourcePage = navHelper.FindByFilename(siteID, sourceURL);
            }

            return(SendTrackback());
        }
Beispiel #8
0
        public string SendTrackback(Guid sourceGuid, Guid siteID, string sTgtURL)
        {
            this.DestinationUrl = new Uri(sTgtURL);
            this.BlogSite       = SiteData.GetSiteFromCache(siteID);

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                this.SourcePage = navHelper.GetLatestVersion(siteID, sourceGuid);
            }

            return(SendTrackback());
        }
Beispiel #9
0
        internal ContentPage(vw_carrot_Content c)
        {
            if (c != null)
            {
                SiteData site = SiteData.GetSiteFromCache(c.SiteID);

                this.Root_ContentID   = c.Root_ContentID;
                this.SiteID           = c.SiteID;
                this.Heartbeat_UserId = c.Heartbeat_UserId;
                this.EditHeartbeat    = c.EditHeartbeat;
                this.FileName         = c.FileName;

                this.CreateUserId = c.CreateUserId;
                this.CreateDate   = site.ConvertUTCToSiteTime(c.CreateDate);

                this.GoLiveDate = site.ConvertUTCToSiteTime(c.GoLiveDate);
                this.RetireDate = site.ConvertUTCToSiteTime(c.RetireDate);
                this.EditDate   = site.ConvertUTCToSiteTime(c.EditDate);

                this.ShowInSiteMap = c.ShowInSiteMap;
                this.BlockIndex    = c.BlockIndex;
                this.PageActive    = c.PageActive;
                this.ShowInSiteNav = c.ShowInSiteNav;

                this.PageSlug    = c.PageSlug;
                this.ContentType = ContentPageType.GetTypeByID(c.ContentTypeID);

                this.ContentID        = c.ContentID;
                this.Parent_ContentID = c.Parent_ContentID;
                this.IsLatestVersion  = c.IsLatestVersion;
                this.TitleBar         = c.TitleBar;
                this.NavMenuText      = c.NavMenuText;
                this.PageHead         = c.PageHead;
                this.PageText         = c.PageText;
                this.LeftPageText     = c.LeftPageText;
                this.RightPageText    = c.RightPageText;
                this.NavOrder         = c.NavOrder;
                this.EditUserId       = c.EditUserId;
                this.CreditUserId     = c.CreditUserId;
                this.TemplateFile     = c.TemplateFile;
                this.Thumbnail        = c.PageThumbnail;

                if (String.IsNullOrEmpty(this.PageSlug) && this.ContentType == ContentPageType.PageType.BlogEntry)
                {
                    this.PageSlug = c.FileName;
                }

                this.MetaDescription = c.MetaDescription;
                this.MetaKeyword     = c.MetaKeyword;

                this.VersionCount = c.VersionCount.HasValue ? c.VersionCount.Value : 0;
            }
        }
Beispiel #10
0
        public void SavePageEdit()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                SiteData site = SiteData.GetSiteFromCache(this.SiteID);

                if (this.Root_ContentID == Guid.Empty)
                {
                    this.Root_ContentID = Guid.NewGuid();
                }
                if (this.ContentID == Guid.Empty)
                {
                    this.ContentID = Guid.NewGuid();
                }
                if (this.Parent_ContentID == Guid.Empty)
                {
                    this.Parent_ContentID = null;
                }

                carrot_RootContent rc = CompiledQueries.cqGetRootContentTbl(_db, this.SiteID, this.Root_ContentID);

                carrot_Content oldC = CompiledQueries.cqGetLatestContentTbl(_db, this.SiteID, this.Root_ContentID);

                bool bNew = false;

                if (rc == null)
                {
                    rc = new carrot_RootContent();

                    PerformCommonSaveRoot(site, rc);

                    _db.carrot_RootContents.InsertOnSubmit(rc);
                    bNew = true;
                }

                carrot_Content c = new carrot_Content();
                c.ContentID = Guid.NewGuid();
                if (!bNew)
                {
                    oldC.IsLatestVersion = false;
                }

                PerformCommonSave(site, rc, c);

                _db.carrot_Contents.InsertOnSubmit(c);

                SaveKeywordsAndTags(_db);

                _db.SubmitChanges();

                SaveTrackbacks();
            }
        }
Beispiel #11
0
 internal TrackBackEntry(vw_carrot_TrackbackQueue c)
 {
     if (c != null)
     {
         SiteData site = SiteData.GetSiteFromCache(c.SiteID);
         this.TrackbackQueueID  = c.TrackbackQueueID;
         this.Root_ContentID    = c.Root_ContentID;
         this.TrackBackURL      = c.TrackBackURL;
         this.TrackBackResponse = c.TrackBackResponse;
         this.CreateDate        = site.ConvertUTCToSiteTime(c.CreateDate);
         this.ModifiedDate      = site.ConvertUTCToSiteTime(c.ModifiedDate);
         this.TrackedBack       = c.TrackedBack;
     }
 }
		internal ContentCategory(vw_carrot_CategoryCounted c) {
			if (c != null) {
				this.ContentCategoryID = c.ContentCategoryID;
				this.SiteID = c.SiteID;
				this.CategorySlug = ContentPageHelper.ScrubSlug(c.CategorySlug);
				this.CategoryText = c.CategoryText;
				this.UseCount = c.UseCount;
				this.PublicUseCount = 1;
				this.IsPublic = c.IsPublic;

				SiteData site = SiteData.GetSiteFromCache(c.SiteID);
				if (site != null) {
					this.CategoryURL = ContentPageHelper.ScrubFilename(c.ContentCategoryID, String.Format("/{0}/{1}", site.BlogCategoryPath, c.CategorySlug));
				}
			}
		}
        public List <ContentDateTally> GetMonthBlogUpdateList(Guid siteID, int iUpdates, bool bActiveOnly)
        {
            SiteData site = SiteData.GetSiteFromCache(siteID);

            List <carrot_ContentTally> lstContentTally = db.carrot_BlogMonthlyTallies(siteID, bActiveOnly, iUpdates).ToList();

            List <ContentDateTally> lstContent = (from ct in lstContentTally
                                                  orderby ct.DateMonth descending
                                                  select(new ContentDateTally {
                DateCaption = ct.DateSlug,
                TallyDate = ct.DateMonth ?? DateTime.Now,
                UseCount = ct.ContentCount ?? 0,
                TheSite = site
            })).ToList();

            return(lstContent);
        }
		internal ContentCategory(vw_carrot_CategoryURL c) {
			if (c != null) {
				SiteData site = SiteData.GetSiteFromCache(c.SiteID);

				this.ContentCategoryID = c.ContentCategoryID;
				this.SiteID = c.SiteID;
				this.CategoryURL = ContentPageHelper.ScrubFilename(c.ContentCategoryID, c.CategoryUrl);
				this.CategoryText = c.CategoryText;
				this.UseCount = c.UseCount;
				this.PublicUseCount = c.PublicUseCount;
				this.IsPublic = c.IsPublic;

				if (c.EditDate.HasValue) {
					this.EditDate = site.ConvertUTCToSiteTime(c.EditDate.Value);
				}
			}
		}
Beispiel #15
0
        public void SaveTrackbackTop()
        {
            SiteData site = SiteData.GetSiteFromCache(this.SiteID);

            if (this.IsLatestVersion && site.SendTrackbacks)
            {
                TrackBackEntry t = TrackBackEntry.GetTrackBackQueue(this.Root_ContentID).FirstOrDefault();
                if (t != null && t.CreateDate > site.Now.AddMinutes(-10))
                {
                    try {
                        TrackBacker tb = new TrackBacker();
                        t.TrackBackResponse = tb.SendTrackback(t.Root_ContentID, site.SiteID, t.TrackBackURL);
                        t.TrackedBack       = true;
                        t.Save();
                    } catch (Exception ex) { }
                }
            }
        }
Beispiel #16
0
        public List <IContentMetaInfo> GetMonthBlogUpdateList(Guid siteID, int iUpdates, bool bActiveOnly)
        {
            SiteData site = SiteData.GetSiteFromCache(siteID);

            List <carrot_ContentTally> lstContentTally = db.carrot_BlogMonthlyTallies(siteID, bActiveOnly, iUpdates).ToList();

            List <IContentMetaInfo> lstContent = (from ct in lstContentTally
                                                  orderby ct.DateMonth descending
                                                  select(IContentMetaInfo)(
                                                      new ContentDateTally {
                DateCaption = ct.DateSlug,
                GoLiveDate = Convert.ToDateTime(ct.DateMonth),
                UseCount = Convert.ToInt32(ct.ContentCount),
                TheSite = site,
                TallyID = Guid.NewGuid()
            })).ToList();

            return(lstContent);
        }
Beispiel #17
0
        internal ContentTag(carrot_ContentTag c)
        {
            if (c != null)
            {
                this.ContentTagID   = c.ContentTagID;
                this.SiteID         = c.SiteID;
                this.TagSlug        = ContentPageHelper.ScrubSlug(c.TagSlug);
                this.TagText        = c.TagText;
                this.IsPublic       = c.IsPublic;
                this.UseCount       = 1;
                this.PublicUseCount = 1;

                SiteData site = SiteData.GetSiteFromCache(c.SiteID);
                if (site != null)
                {
                    this.TagURL = ContentPageHelper.ScrubFilename(c.ContentTagID, String.Format("/{0}/{1}", site.BlogTagPath, c.TagSlug));
                }
            }
        }
Beispiel #18
0
        public void SavePageAsDraft()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                SiteData site = SiteData.GetSiteFromCache(this.SiteID);

                if (this.Root_ContentID == Guid.Empty)
                {
                    this.Root_ContentID = Guid.NewGuid();
                }
                if (this.ContentID == Guid.Empty)
                {
                    this.ContentID = Guid.NewGuid();
                }

                carrot_RootContent rc = CompiledQueries.cqGetRootContentTbl(_db, this.SiteID, this.Root_ContentID);

                if (rc == null)
                {
                    rc = new carrot_RootContent();

                    PerformCommonSaveRoot(site, rc);

                    _db.carrot_RootContents.InsertOnSubmit(rc);
                }

                carrot_Content c = new carrot_Content();
                c.ContentID = Guid.NewGuid();

                PerformCommonSave(site, rc, c);

                c.IsLatestVersion = false;                 // draft, leave existing version latest

                _db.carrot_Contents.InsertOnSubmit(c);

                SaveKeywordsAndTags(_db);

                _db.SubmitChanges();

                this.IsLatestVersion = c.IsLatestVersion;
                SaveTrackbacks();
            }
        }
Beispiel #19
0
        internal BasicContentData(vw_carrot_Content c)
        {
            if (c != null)
            {
                SiteData site = SiteData.GetSiteFromCache(c.SiteID);

                this.SiteID           = c.SiteID;
                this.Root_ContentID   = c.Root_ContentID;
                this.PageActive       = c.PageActive;
                this.Parent_ContentID = c.Parent_ContentID;
                this.FileName         = c.FileName;
                this.TemplateFile     = c.TemplateFile;
                this.NavOrder         = c.NavOrder;

                this.ContentType = ContentPageType.GetTypeByID(c.ContentTypeID);
                this.CreateDate  = site.ConvertUTCToSiteTime(c.CreateDate);
                this.GoLiveDate  = site.ConvertUTCToSiteTime(c.GoLiveDate);
                this.RetireDate  = site.ConvertUTCToSiteTime(c.RetireDate);
            }
        }
Beispiel #20
0
        internal ContentEditor(vw_carrot_EditorURL c)
        {
            if (c != null)
            {
                SiteData site = SiteData.GetSiteFromCache(c.SiteID);

                this.UserId         = c.UserId;
                this.SiteID         = c.SiteID;
                this.UserUrl        = c.UserUrl;
                this.LoweredEmail   = c.LoweredEmail;
                this.UseCount       = c.UseCount;
                this.PublicUseCount = c.PublicUseCount;
                this.IsPublic       = true;

                if (c.EditDate.HasValue)
                {
                    this.EditDate = site.ConvertUTCToSiteTime(c.EditDate.Value);
                }
            }
        }
Beispiel #21
0
        internal ContentTag(vw_carrot_TagURL c)
        {
            if (c != null)
            {
                SiteData site = SiteData.GetSiteFromCache(c.SiteID);

                this.ContentTagID   = c.ContentTagID;
                this.SiteID         = c.SiteID;
                this.TagURL         = c.TagUrl;
                this.TagText        = c.TagText;
                this.UseCount       = c.UseCount;
                this.PublicUseCount = c.PublicUseCount;
                this.IsPublic       = c.IsPublic;

                if (c.EditDate.HasValue)
                {
                    this.EditDate = site.ConvertUTCToSiteTime(c.EditDate.Value);
                }
            }
        }
        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();
        }
Beispiel #23
0
        public void SaveTrackbacks()
        {
            SiteData site = SiteData.GetSiteFromCache(this.SiteID);

            if (!String.IsNullOrEmpty(this.NewTrackBackURLs))
            {
                this.NewTrackBackURLs = this.NewTrackBackURLs.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n\n", "\n");
                string[] TBURLs = this.NewTrackBackURLs.Split('\n');
                foreach (string sURL in TBURLs)
                {
                    List <TrackBackEntry> lstTB = TrackBackEntry.FindTrackbackByURL(this.Root_ContentID, sURL);
                    if (lstTB.Count < 1)
                    {
                        TrackBackEntry tbe = new TrackBackEntry {
                            Root_ContentID = this.Root_ContentID,
                            TrackBackURL   = sURL,
                            TrackedBack    = false
                        };

                        tbe.Save();
                    }
                }
            }

            if (this.IsLatestVersion && site.SendTrackbacks)
            {
                List <TrackBackEntry> lstTBQ = TrackBackEntry.GetTrackBackQueue(this.Root_ContentID);
                foreach (TrackBackEntry t in lstTBQ)
                {
                    if (t.CreateDate > site.Now.AddMinutes(-10))
                    {
                        try {
                            TrackBacker tb = new TrackBacker();
                            t.TrackBackResponse = tb.SendTrackback(t.Root_ContentID, site.SiteID, t.TrackBackURL);
                            t.TrackedBack       = true;
                            t.Save();
                        } catch (Exception ex) { }
                    }
                }
            }
        }
Beispiel #24
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();
        }
Beispiel #25
0
        private SiteNav GetParentPageNavigationByNav(Guid siteID, SiteNav navItem)
        {
            if (navItem != null)
            {
                if (navItem.ContentType == ContentPageType.PageType.BlogEntry)
                {
                    Guid?parentPageID = SiteData.GetSiteFromCache(siteID).Blog_Root_ContentID;
                    navItem.Parent_ContentID = parentPageID;
                }

                SiteNav content = null;
                if (navItem != null && navItem.Parent_ContentID.HasValue)
                {
                    content = new SiteNav(CompiledQueries.GetLatestContentByID(db, siteID, false, navItem.Parent_ContentID.Value));
                }

                return(content);
            }
            else
            {
                return(null);
            }
        }
        public void Save()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                SiteData site = SiteData.GetSiteFromCache(this.SiteID);

                carrot_RootContentSnippet rc = CompiledQueries.cqGetSnippetDataTbl(_db, this.SiteID, this.Root_ContentSnippetID);

                carrot_ContentSnippet oldC = CompiledQueries.cqGetLatestSnippetContentTbl(_db, this.SiteID, this.Root_ContentSnippetID);

                bool bNew = false;

                if (rc == null)
                {
                    rc = new carrot_RootContentSnippet();
                    rc.Root_ContentSnippetID = Guid.NewGuid();
                    rc.SiteID = site.SiteID;

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

                    _db.carrot_RootContentSnippets.InsertOnSubmit(rc);
                    bNew = true;
                }

                this.ContentSnippetSlug = ContentPageHelper.ScrubSlug(this.ContentSnippetSlug);

                rc.ContentSnippetActive = this.ContentSnippetActive;
                rc.ContentSnippetName   = this.ContentSnippetName;
                rc.ContentSnippetSlug   = this.ContentSnippetSlug;

                rc.GoLiveDate = site.ConvertSiteTimeToUTC(this.GoLiveDate);
                rc.RetireDate = site.ConvertSiteTimeToUTC(this.RetireDate);

                carrot_ContentSnippet c = new carrot_ContentSnippet();
                c.ContentSnippetID      = Guid.NewGuid();
                c.Root_ContentSnippetID = rc.Root_ContentSnippetID;
                c.IsLatestVersion       = true;

                if (!bNew)
                {
                    oldC.IsLatestVersion = false;
                }

                c.EditDate = DateTime.UtcNow;
                if (this.EditUserId != Guid.Empty)
                {
                    c.EditUserId = this.EditUserId;
                }
                else
                {
                    c.EditUserId = SecurityData.CurrentUserGuid;
                }

                c.ContentBody = this.ContentBody;

                rc.Heartbeat_UserId = c.EditUserId;
                rc.EditHeartbeat    = DateTime.UtcNow;

                _db.carrot_ContentSnippets.InsertOnSubmit(c);

                _db.SubmitChanges();

                this.ContentSnippetID      = c.ContentSnippetID;
                this.Root_ContentSnippetID = rc.Root_ContentSnippetID;
            }
        }