Example #1
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();
            }
        }
 internal static IQueryable <vw_carrot_Content> GetLatestContentByParent(CarrotCMSDataContext ctx, Guid siteID, string parentPage, bool bActiveOnly)
 {
     return(from ct in ctx.vw_carrot_Contents
            join cp in ctx.vw_carrot_ContentChilds on ct.Root_ContentID equals cp.Root_ContentID
            orderby ct.NavOrder, ct.NavMenuText
            where ct.SiteID == siteID &&
            cp.ParentFileName.ToLower() == parentPage.ToLower() &&
            ct.IsLatestVersion == true &&
            (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> GetAllByTypeList(CarrotCMSDataContext ctx, Guid siteID, bool bActiveOnly, ContentPageType.PageType entryType)
 {
     return(from ct in ctx.vw_carrot_Contents
            orderby ct.NavOrder, ct.NavMenuText
            where ct.SiteID == siteID &&
            ct.IsLatestVersion == true &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false) &&
            ct.IsLatestVersion == true &&
            ct.ContentTypeID == ContentPageType.GetIDByType(entryType)
            select ct);
 }
 internal static IQueryable <vw_carrot_Content> GetLatestContentByParent(CarrotCMSDataContext ctx, Guid siteID, Guid?parentContentID, bool bActiveOnly)
 {
     return(from ct in ctx.vw_carrot_Contents
            orderby ct.NavOrder, ct.NavMenuText
            where ct.SiteID == siteID &&
            ct.Parent_ContentID == parentContentID &&
            ct.Parent_ContentID != null &&
            ct.IsLatestVersion == true &&
            (ct.PageActive == true || bActiveOnly == false) &&
            (ct.GoLiveDate < DateTime.UtcNow || bActiveOnly == false) &&
            (ct.RetireDate > DateTime.UtcNow || bActiveOnly == false)
            select ct);
 }
        public static List <ContentCategory> BuildCategoryList(Guid rootContentID)
        {
            List <ContentCategory> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                IQueryable <vw_carrot_CategoryURL> query = CompiledQueries.cqGetContentCategoryByContentID(_db, rootContentID);

                _types = (from d in query.ToList()
                          select new ContentCategory(d)).ToList();
            }

            return(_types);
        }
Example #7
0
        public static List <TrackBackEntry> GetPageTrackBackList(Guid rootContentID)
        {
            List <TrackBackEntry> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                IQueryable <vw_carrot_TrackbackQueue> query = CompiledQueries.cqGetTrackbackByRootID(_db, rootContentID);

                _types = (from d in query.ToList()
                          select new TrackBackEntry(d)).ToList();
            }

            return(_types);
        }
Example #8
0
        public static List <ContentTag> BuildTagList(Guid rootContentID)
        {
            List <ContentTag> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                IQueryable <carrot_ContentTag> query = CompiledQueries.cqGetContentTagByContentID(_db, rootContentID);

                _types = (from d in query.ToList()
                          select new ContentTag(d)).ToList();
            }

            return(_types);
        }
Example #9
0
        public void ApplyTemplate()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_Content c = CompiledQueries.cqGetLatestContentTbl(_db, this.SiteID, this.Root_ContentID);

                if (c != null)
                {
                    c.TemplateFile = this.TemplateFile;

                    _db.SubmitChanges();
                }
            }
        }
Example #10
0
        public static List <TextWidget> GetSiteTextWidgets(Guid siteID)
        {
            List <TextWidget> _lst = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                IQueryable <carrot_TextWidget> query = CompiledQueries.cqTextWidgetBySiteID(_db, siteID);

                _lst = (from d in query.ToList()
                        select new TextWidget(d)).ToList();
            }

            return(_lst);
        }
Example #11
0
        public static List <TrackBackEntry> FindTrackbackByURL(Guid rootContentID, string sURL)
        {
            List <TrackBackEntry> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <vw_carrot_TrackbackQueue> query = CompiledQueries.cqGetTrackbackByRootIDAndUrl(_db, rootContentID, sURL);

                _types = (from d in query.ToList()
                          select new TrackBackEntry(d)).ToList();
            }

            return(_types);
        }
Example #12
0
        public static List <TrackBackEntry> GetTrackBackSiteQueue(Guid siteID)
        {
            List <TrackBackEntry> _types = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                IQueryable <vw_carrot_TrackbackQueue> query = CompiledQueries.cqGetTrackbackBySiteIDUnTracked(_db, siteID);

                _types = (from d in query.ToList()
                          select new TrackBackEntry(d)).ToList();
            }

            return(_types);
        }
        internal static List <string> GetSiteDirectoryPaths()
        {
            List <string> lstContent = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                lstContent = (from ct in _db.vw_carrot_Contents
                              where ct.IsLatestVersion == true &&
                              ct.FileName.ToLower().EndsWith(SiteData.DefaultDirectoryFilename)
                              select ct.FileName.ToLower()).Distinct().ToList();
            }

            return(lstContent);
        }
        public static ContentSnippet GetSnippetBySlug(Guid siteID, string categorySlug, bool bActiveOnly)
        {
            ContentSnippet _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                vw_carrot_ContentSnippet query = CompiledQueries.GetLatestContentSnippetBySlug(_db, siteID, bActiveOnly, categorySlug);
                if (query != null)
                {
                    _item = new ContentSnippet(query);
                }
            }

            return(_item);
        }
Example #15
0
        public static ContentTag Get(Guid TagID)
        {
            ContentTag _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_ContentTag query = CompiledQueries.cqGetContentTagByID(_db, TagID);
                if (query != null)
                {
                    _item = new ContentTag(query);
                }
            }

            return(_item);
        }
Example #16
0
        public static TextWidget Get(Guid textWidgetID)
        {
            TextWidget _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_TextWidget query = CompiledQueries.cqTextWidgetByID(_db, textWidgetID);
                if (query != null)
                {
                    _item = new TextWidget(query);
                }
            }

            return(_item);
        }
        public static ContentCategory Get(Guid CategoryID)
        {
            ContentCategory _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_ContentCategory query = CompiledQueries.cqGetContentCategoryByID(_db, CategoryID);
                if (query != null)
                {
                    _item = new ContentCategory(query);
                }
            }

            return(_item);
        }
Example #18
0
        public static ContentSnippet Get(Guid rootSnippetID)
        {
            ContentSnippet _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_ContentSnippet query = CompiledQueries.cqGetLatestSnippetVersion(_db, rootSnippetID);
                if (query != null)
                {
                    _item = new ContentSnippet(query);
                }
            }

            return(_item);
        }
Example #19
0
        public static ContentEditor Get(Guid SiteID, Guid UserID)
        {
            ContentEditor _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_EditorURL query = CompiledQueries.cqGetContentEditorByID(_db, SiteID, UserID);
                if (query != null)
                {
                    _item = new ContentEditor(query);
                }
            }

            return(_item);
        }
Example #20
0
        public static List <MembershipUser> GetUserSearch(string searchTerm)
        {
            List <MembershipUser> usrs = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                usrs = (from u in _db.aspnet_Users
                        join m in _db.aspnet_Memberships on u.UserId equals m.UserId
                        where u.UserName.Contains(searchTerm) ||
                        m.Email.Contains(searchTerm)
                        select Membership.GetUser(u.UserName)).Take(50).ToList();
            }

            return(usrs);
        }
Example #21
0
        public static ContentTag GetByURL(Guid SiteID, string requestedURL)
        {
            ContentTag _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                vw_carrot_TagURL query = CompiledQueries.cqGetContentTagByURL(_db, SiteID, requestedURL);
                if (query != null)
                {
                    _item = new ContentTag(query);
                }
            }

            return(_item);
        }
Example #22
0
        public static ContentEditor GetByURL(Guid SiteID, string requestedURL)
        {
            ContentEditor _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_EditorURL query = CompiledQueries.cqGetContentEditorURL(_db, SiteID, requestedURL);
                if (query != null)
                {
                    _item = new ContentEditor(query);
                }
            }

            return(_item);
        }
        public static ContentSnippet GetVersion(Guid snippetDataID)
        {
            ContentSnippet _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                vw_carrot_ContentSnippet query = CompiledQueries.cqGetSnippetVersionByID(_db, snippetDataID);
                if (query != null)
                {
                    _item = new ContentSnippet(query);
                }
            }

            return(_item);
        }
Example #24
0
        public static ContentSnippet GetSnippetByID(Guid siteID, Guid rootSnippetID, bool bActiveOnly)
        {
            ContentSnippet _item = null;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                vw_carrot_ContentSnippet query = CompiledQueries.GetLatestContentSnippetByID(_db, siteID, bActiveOnly, rootSnippetID);
                if (query != null)
                {
                    _item = new ContentSnippet(query);
                }
            }

            return(_item);
        }
Example #25
0
        public Guid GetCurrentEditUser()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_RootContentSnippet rc = CompiledQueries.cqGetSnippetDataTbl(_db, this.SiteID, this.Root_ContentSnippetID);

                if (rc != null)
                {
                    return((Guid)rc.Heartbeat_UserId);
                }
                else
                {
                    return(Guid.Empty);
                }
            }
        }
Example #26
0
        public static string GetSerialized(Guid itemID, string sKey)
        {
            string sData = String.Empty;

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                carrot_SerialCache itm = CompiledQueries.SearchSeriaCache(_db, itemID, sKey);

                if (itm != null)
                {
                    sData = itm.SerializedData;
                }
            }

            return(sData);
        }
 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);
 }
		public void Delete() {
			using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
				carrot_ContentCategory s = CompiledQueries.cqGetContentCategoryByID(_db, this.ContentCategoryID);

				if (s != null) {
					IQueryable<carrot_CategoryContentMapping> lst = (from m in _db.carrot_CategoryContentMappings
																	 where m.ContentCategoryID == s.ContentCategoryID
																	 select m);

					_db.carrot_CategoryContentMappings.BatchDelete(lst);
					_db.carrot_ContentCategories.DeleteOnSubmit(s);
					_db.SubmitChanges();
				}
			}
		}
 public static ExtendedUserData GetEditorFromURL()
 {
     using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
         vw_carrot_EditorURL query = CompiledQueries.cqGetEditorByURL(_db, SiteData.CurrentSiteID, SiteData.CurrentScriptName);
         if (query != null)
         {
             ExtendedUserData usr = new ExtendedUserData(query.UserId);
             return(usr);
         }
         else
         {
             return(null);
         }
     }
 }
        public ExtendedUserData GetCurrentEditUserData()
        {
            using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) {
                carrot_RootContentSnippet rc = CompiledQueries.cqGetSnippetDataTbl(_db, this.SiteID, this.Root_ContentSnippetID);

                if (rc != null)
                {
                    return(new ExtendedUserData((Guid)rc.Heartbeat_UserId));
                }
                else
                {
                    return(null);
                }
            }
        }