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; } }