Exemple #1
0
        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();
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        public void TestFindElementByGuid()
        {
            // first add an element to a doc
            DocModel doc      = new DocModel();
            Element  expected = new Element();

            doc.AddElement(expected);

            Guid ExpectedGuid = expected.ElementId;

            Element actual = doc.GetElementByGuid(ExpectedGuid);

            Debug.Equals(actual, expected);
        }
Exemple #5
0
        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);
            }
        }