protected void btnSave_Click(object sender, System.EventArgs e) { lblMessage.Text = string.Empty; // If a previous version of the content exists, mark it as old. // Also, maintain a max of 10 recs in the version history QuickContentContentCollection coll = new QuickContentContentCollection() .Where(QuickContentContent.Columns.ContentName, ContentName) .Where(QuickContentContent.Columns.Culture, ddlCulture.SelectedValue) .OrderByDesc(QuickContentContent.Columns.CreatedOn) .Load(); int i = 1; foreach (QuickContentContent rec in coll) { if (i >= MAX_CONTENT_HISTORY_RECS) { QuickContentContent.Delete(rec.Id); } else if (rec.StatusId == 2) { rec.StatusId = 3; // 3 = Past Content rec.Save(); } i++; } // Insert the latest content QuickContentContent newContent = new QuickContentContent(true); newContent.IsNew = true; newContent.StatusId = 2; // 2 = Active Content newContent.Culture = ddlCulture.SelectedValue; newContent.ContentName = ContentName; newContent.Body = txtContent.Value; newContent.Save(Page.User.Identity.Name); // Reload version dropdown SetEditableContent(true); lblMessage.Text = "<br>Your changes have been saved."; }
public bool Delete(object Id) { return(QuickContentContent.Delete(Id) == 1); }