public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) { bool bNew = false; carrot_ContentCategory s = CompiledQueries.cqGetContentCategoryByID(_db, this.ContentCategoryID); if (s == null || (s != null && s.ContentCategoryID == Guid.Empty)) { s = new carrot_ContentCategory(); s.ContentCategoryID = Guid.NewGuid(); s.SiteID = this.SiteID; bNew = true; } s.CategorySlug = ContentPageHelper.ScrubSlug(this.CategorySlug); s.CategoryText = this.CategoryText; s.IsPublic = this.IsPublic; if (bNew) { _db.carrot_ContentCategories.InsertOnSubmit(s); } _db.SubmitChanges(); this.ContentCategoryID = s.ContentCategoryID; } }
internal ContentCategory(carrot_ContentCategory c) { if (c != null) { this.ContentCategoryID = c.ContentCategoryID; this.SiteID = c.SiteID; this.CategorySlug = c.CategorySlug; this.CategoryText = c.CategoryText; this.IsPublic = c.IsPublic; } }
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; }
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(); } } }
internal ContentCategory(carrot_ContentCategory c) { if (c != null) { this.ContentCategoryID = c.ContentCategoryID; this.SiteID = c.SiteID; this.CategorySlug = ContentPageHelper.ScrubSlug(c.CategorySlug); this.CategoryText = c.CategoryText; this.IsPublic = c.IsPublic; this.UseCount = 1; this.PublicUseCount = 1; SiteData site = SiteData.GetSiteFromCache(c.SiteID); if (site != null) { this.CategoryURL = ContentPageHelper.ScrubFilename(c.ContentCategoryID, String.Format("/{0}/{1}", site.BlogCategoryPath, c.CategorySlug)); } } }
internal ContentCategory(carrot_ContentCategory c) { if (c != null) { this.ContentCategoryID = c.ContentCategoryID; this.SiteID = c.SiteID; this.CategorySlug = ContentPageHelper.ScrubSlug(c.CategorySlug); this.CategoryText = c.CategoryText; this.IsPublic = c.IsPublic; this.UseCount = 1; this.PublicUseCount = 1; SiteData site = SiteData.GetSiteFromCache(c.SiteID); if (site != null) { this.CategoryURL = ContentPageHelper.ScrubFilename(c.ContentCategoryID, String.Format("/{0}/{1}.aspx", site.BlogCategoryPath, c.CategorySlug.Trim())); } } }
public void Save() { using (CarrotCMSDataContext _db = CarrotCMSDataContext.GetDataContext()) { bool bNew = false; carrot_ContentCategory s = CompiledQueries.cqGetContentCategoryByID(_db, this.ContentCategoryID); if (s == null || (s != null && s.ContentCategoryID == Guid.Empty)) { s = new carrot_ContentCategory(); s.ContentCategoryID = Guid.NewGuid(); s.SiteID = this.SiteID; bNew = true; } s.CategorySlug = ContentPageHelper.ScrubSlug(this.CategorySlug); s.CategoryText = this.CategoryText; s.IsPublic = this.IsPublic; if (bNew) { _db.carrot_ContentCategories.InsertOnSubmit(s); } _db.SubmitChanges(); this.ContentCategoryID = s.ContentCategoryID; } }