protected void btnSave_Click(object sender, EventArgs e) { ContentSnippet item = null; if (guidRootItemID != Guid.Empty) { item = ContentSnippet.Get(guidRootItemID); } else { item = ContentSnippet.GetVersion(guidVersionItemID); } if (item == null || (item != null && item.Root_ContentSnippetID == Guid.Empty)) { item = new ContentSnippet(SiteData.CurrentSiteID); item.CreateUserId = SecurityData.CurrentUserGuid; } item.ContentSnippetSlug = txtSlug.Text; item.ContentSnippetName = txtLabel.Text; item.ContentBody = reBody.Text; item.EditUserId = SecurityData.CurrentUserGuid; item.ContentSnippetActive = chkPublic.Checked; item.GoLiveDate = Convert.ToDateTime(txtReleaseDate.Text + " " + txtReleaseTime.Text); item.RetireDate = Convert.ToDateTime(txtRetireDate.Text + " " + txtRetireTime.Text); item.Save(); Response.Redirect(SiteData.CurrentScriptName + "?id=" + item.Root_ContentSnippetID.ToString()); }
public bool IsUniqueSlug() { string theFileName = this.ContentSnippetSlug; int iCount = ContentSnippet.GetSimilar(this.SiteID, this.Root_ContentSnippetID, this.ContentSnippetSlug); if (iCount < 1) { return(true); } return(false); }
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); }
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); }
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); }
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); }
public ActionResult DeleteContentSnippet(ContentSnippet model) { ContentSnippet item = ContentSnippet.Get(model.Root_ContentSnippetID); item.Delete(); return RedirectToAction("ContentSnippetIndex"); }
public ActionResult ContentSnippetAddEdit(ContentSnippet model, string mode) { ViewBag.ContentEditMode = (String.IsNullOrEmpty(mode) || mode.Trim().ToLowerInvariant() != "raw") ? "html" : "raw"; Helper.ForceValidation(ModelState, model); if (ModelState.IsValid) { ContentSnippet item = ContentSnippet.Get(model.Root_ContentSnippetID); if (item == null) { item = new ContentSnippet(); item.Root_ContentSnippetID = Guid.Empty; item.SiteID = SiteID; item.CreateUserId = SecurityData.CurrentUserGuid; item.CreateDate = SiteData.CurrentSite.Now; } item.GoLiveDate = model.GoLiveDate; item.RetireDate = model.RetireDate; item.EditUserId = SecurityData.CurrentUserGuid; item.ContentSnippetName = model.ContentSnippetName; item.ContentSnippetSlug = model.ContentSnippetSlug; item.ContentSnippetActive = model.ContentSnippetActive; item.ContentBody = model.ContentBody; item.Save(); return RedirectToAction("ContentSnippetAddEdit", new { @id = item.Root_ContentSnippetID, @mode = mode }); } Helper.HandleErrorDict(ModelState); return View(model); }
public ActionResult ContentSnippetAddEdit(Guid? id, Guid? versionid, string mode) { ViewBag.ContentEditMode = (String.IsNullOrEmpty(mode) || mode.Trim().ToLowerInvariant() != "raw") ? "html" : "raw"; ContentSnippet model = null; if (id.HasValue) { model = ContentSnippet.Get(id.Value); } if (versionid.HasValue) { model = ContentSnippet.Get(versionid.Value); } if (model == null) { model = new ContentSnippet(); DateTime dtSite = CMSConfigHelper.CalcNearestFiveMinTime(SiteData.CurrentSite.Now); model.GoLiveDate = dtSite; model.RetireDate = dtSite.AddYears(200); model.Root_ContentSnippetID = Guid.Empty; } return View(model); }
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; }
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; }
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; }
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; }