/// <summary> /// Fills the properties of a content revision object. /// </summary> /// <param name="e">The IContentEntity object.</param> /// <param name="r">The IContentRevision object.</param> private void FillRevision(IContentEntity e, IContentRevision r) { r.ContentID = e.ContentID; r.IsLive = true; r.TimeStamp = DateTime.Now; r.VersionID = GenerateNewRevisionID(); e.CurrentRevision = r.VersionID; }
/// <summary> /// Saves rows of data for /// </summary> /// <param name="r">An IContentRevision object.</param> /// <param name="rows">A list of content row data.</param> public void SaveRows(IContentRevision r, List <ContentRow> rows) { var data = new Data.ContentRepository(); foreach (var row in rows) { data.SaveRow(r, row); } }
/// <summary> /// Loads content and revisions for editing. /// </summary> private void LoadExistingContent() { if (_contentID.HasValue) { _contentEntity = _content.GetContentEntity(_contentID.Value); ValidateCurrentSite(); _contentRevisions = _content.LoadRevisions(_contentID.Value, _siteID); _currentRevision = ((List <IContentRevision>)_contentRevisions).Find(i => i.VersionID == _contentEntity.CurrentRevision); } else { // this is new content, so assign some IDs for use throughout the page _contentID = Guid.NewGuid(); } }
/// <summary> /// Fills the properties of a content row (bucket / embeddable) object. /// </summary> /// <param name="r">The IContentRevision object.</param> /// <param name="rows">The list of content rows.</param> private void FillContentRows(IContentRevision r, List <ContentRow> rows) { var embeddables = (List <string>)ViewState["embeddables"]; if (embeddables == null) { return; } foreach (var entry in embeddables.Select(embeddable => embeddable.Split('|'))) { string[] chunks = entry[0].Split(':'); ContentRow row = new ContentRow(); switch (chunks[1]) { case "AddHeaderEmbeddableRow": row.bucketID = 1; break; case "AddPrimaryNavEmbeddableRow": row.bucketID = 2; break; case "AddContentEmbeddableRow": row.bucketID = 3; break; case "AddSubNavEmbeddableRow": row.bucketID = 4; break; case "AddFooterEmbeddableRow": row.bucketID = 5; break; default: break; } row.embeddableID = Convert.ToInt32(entry[1]); row.contentID = r.VersionID; rows.Add(row); } }
/// <summary> /// Saves a row of content control information. /// </summary> /// <param name="r">An IContentRevision object.</param> /// <param name="row">A ContentRow object.</param> public void SaveRow(IContentRevision r, ContentRow row) { using (SqlConnection conn = (SqlConnection)_factory.GetConnection()) { SqlCommand comm = (SqlCommand)_factory.GetCommand("InsertContentRow"); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@versionID", r.VersionID); comm.Parameters.AddWithValue("@bucketID", row.bucketID); comm.Parameters.AddWithValue("@embeddableID", row.embeddableID); try { conn.Open(); comm.ExecuteNonQuery(); } finally { conn.Close(); } } }
/// <summary> /// Saves a content revision. /// </summary> /// <param name="r">The IContentRevision object.</param> public void SaveRevision(IContentRevision r) { using (SqlConnection conn = (SqlConnection)_factory.GetConnection()) { SqlCommand comm = (SqlCommand)_factory.GetCommand("InsertContentRevision"); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.AddWithValue("@versionID", r.VersionID); comm.Parameters.AddWithValue("@contentID", r.ContentID); comm.Parameters.AddWithValue("@isLive", r.IsLive); comm.Parameters.AddWithValue("@timeStamp", r.TimeStamp); try { conn.Open(); comm.ExecuteNonQuery(); } finally { conn.Close(); } } }
/// <summary> /// Saves a content revision. /// </summary> /// <param name="r">The IContentRevision object.</param> public void SaveRevision(IContentRevision r) { var data = new Data.ContentRepository(); data.SaveRevision(r); }