public static void Behavioral_MementoDemo2() { var doc = new Document(); var history = new DocHistory(); doc.SetContent("Hello World"); history.Push(doc.CreateMemento()); doc.SetFontName("font N1"); history.Push(doc.CreateMemento()); doc.SetFontSize(12); Console.WriteLine(doc.ToString()); doc.Restore(history.Pop()); Console.WriteLine(doc.ToString()); doc.Restore(history.Pop()); Console.WriteLine(doc.ToString()); history.Push(doc.CreateMemento()); // CreateMemento before any change, so you can revert using Restore method doc.SetFontName("font N2"); Console.WriteLine(doc.ToString()); doc.Restore(history.Pop()); Console.WriteLine(doc.ToString()); }
public ActionResult DeleteConfirmed(int id) { DocHistory dochistory = db.DocHistories.Single(d => d.DocHistoryID == id); db.DocHistories.DeleteObject(dochistory); db.SaveChanges(); return(RedirectToAction("Index")); }
public SearchViewModel(SPage page) { this.page = page; Text = new List <string>(); RadioButton_page_Checked = true; document = new Document(); docHistory = new DocHistory(); // RadioButton_site_Checked = false; }
public EditDocViewModel(SPage page, Document document) { this.page = page; this.document = document; this.page = page; Text = document.items; RadioButton_html = true; docHistory = new DocHistory(); docHistory.History.Push(document.SaveState()); }
// // GET: /DocHist/Delete/5 public ActionResult Delete(int id = 0) { DocHistory dochistory = db.DocHistories.Single(d => d.DocHistoryID == id); if (dochistory == null) { return(HttpNotFound()); } return(View(dochistory)); }
// // GET: /DocHist/Edit/5 public ActionResult Edit(int id = 0) { DocHistory dochistory = db.DocHistories.Single(d => d.DocHistoryID == id); if (dochistory == null) { return(HttpNotFound()); } ViewBag.SOPID = new SelectList(db.SOPs, "SOPID", "Name", dochistory.SOPID); return(View(dochistory)); }
public ActionResult Edit(DocHistory dochistory) { if (ModelState.IsValid) { db.DocHistories.Attach(dochistory); db.ObjectStateManager.ChangeObjectState(dochistory, EntityState.Modified); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SOPID = new SelectList(db.SOPs, "SOPID", "Name", dochistory.SOPID); return(View(dochistory)); }
public ActionResult Create(DocHistory dochistory) { if (ModelState.IsValid) { db.DocHistories.AddObject(dochistory); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SOPID = new SelectList(db.SOPs, "SOPID", "Name", dochistory.SOPID); return(View(dochistory)); }
public ServicesResult UpdateDocument(VmDocUpdate vmDocUpdate) { try { var orginalDoc = _document.Find(vmDocUpdate.DocId); if (orginalDoc == null) { return(new ServicesResult() { Success = false, Message = "Document Not Found", }); } var docHistory = new DocHistory() { TypeId = (int)DocHistoryEnumerable.DocHistoryType.EditeDocument, DocId = orginalDoc.DocId, ChangeSet = orginalDoc.Subject + Environment.NewLine + orginalDoc.Content, OwnerUserId = vmDocUpdate.OwnerUserId, OwnerDepartmentId = _chartService.GetDepartment(vmDocUpdate.FolId).ChartId }; orginalDoc.Content = vmDocUpdate.Content; orginalDoc.Subject = vmDocUpdate.Subject; _uow.MarkAsChanged(orginalDoc); _docHistory.Add(docHistory); _uow.SaveChanges(); return(new ServicesResult() { Success = true, Message = "OK", }); } catch (Exception ex) { return(new ServicesResult() { Success = false, Message = ex.Message, InnerExeption = ex.InnerException.Message }); } }