public void EditElement(string title, string type, string ElementId, List <string> updatedItems) { HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); DocModel doc = SerialisationService.GetDoc(title, type); Element element = doc.GetElementByGuid(Guid.Parse(ElementId)); StringBuilder sb = new StringBuilder(); for (int i = 0; i < updatedItems.Count - 1; i++) { sb.Append(updatedItems[i]); } sb.Append(updatedItems[updatedItems.Count - 1]); int pos = doc.Elements.IndexOf(element); doc.Elements.Remove(element); element.Content = sb.ToString(); doc.Elements.Insert(pos, element); UpdateDoc(doc); HttpContext.Current.Response.End(); }
public void ElementDelete(string title, string type, string ElementId) { DocModel doc = SerialisationService.GetDoc(title, type); Element element = doc.GetElementByGuid(Guid.Parse(ElementId)); doc.Elements.Remove(element); UpdateDoc(doc); }
public void DocCreate(string name, string type) { DocModel doc = SerialisationService.GetDoc(name, type); if (doc == null) { DocModel NewDoc = new DocModel(name, type); SerialisationService.SerialiseDoc(NewDoc); } else { throw new Exception("Document : " + name + "-" + type + " already exists - not created."); } }
public void ElementEdit(string title, string type, string elementId, string updatedContent) { HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); DocModel document = SerialisationService.GetDoc(title, type); Element element = document.GetElementByGuid(Guid.Parse(elementId)); int pos = document.Elements.IndexOf(element); document.Elements.Remove(element); element.Content = updatedContent; document.Elements.Insert(pos, element); UpdateDoc(document); HttpContext.Current.Response.End(); }
public void ElementCreate(string DocTitle, string DocType, string ElementContent, string ElementType, int position) { position--; // let's start counting at 1 in the front end.. DocModel doc = SerialisationService.GetDoc(DocTitle, DocType); if (doc.Elements.Count < position) // this should never happen but if it does { // then we'll just stick the element at the bottom position = doc.Elements.Count; } Element element = new Element(); element.Content = ElementContent; element.Type = ElementType; doc.Elements.Insert(position, element); UpdateDoc(doc); }
public void ElementMove(string title, string type, string ElementId, int newPos) { newPos--; // lets just call the first element '1' in the front end.. DocModel doc = SerialisationService.GetDoc(title, type); if (newPos > doc.Elements.Count) { throw new Exception("Doc only has " + doc.Elements.Count + " elements - cannot move to position:" + newPos); } else { Element element = doc.GetElementByGuid(Guid.Parse(ElementId)); doc.Elements.Remove(element); doc.Elements.Insert(newPos, element); UpdateDoc(doc); } }
public string GetDocHtml(string title, string type) { DocModel doc = SerialisationService.GetDoc(title, type); return(HtmlWriter.MakeHtml(doc)); }
public int GetNumElementsInDoc(string title, string type) { DocModel doc = SerialisationService.GetDoc(title, type); return(doc.Elements.Count); }