// Creates wiki public void CreateEntry(WikiDTO wiki) { if (wiki == null) { throw new ArgumentNullException(nameof(wiki)); } // Lock _readWriteLock.EnterWriteLock(); try { // Add new wiki AddWikiEntry(wiki); } finally { // Release lock _readWriteLock.ExitWriteLock(); } }
private void AddWikiEntry(WikiDTO wiki) { // Add all new tags / categories (If they don't already exist in the XML) AddWikiNodes(wiki.Categories, "Categories", "Category", "Title"); AddWikiNodes(wiki.Tags, "Tags", "Tag", "Title"); // Add the WikiEntry XElement wikiEntry = new XElement("WikiEntry", new XAttribute("Id", Guid.NewGuid()), new XAttribute("CreatedBy", "*****@*****.**"), new XAttribute("CreatedAt", DateTimeOffset.UtcNow.ToString()), new XAttribute("UpdatedBy", "*****@*****.**"), new XAttribute("UpdatedAt", DateTimeOffset.UtcNow.ToString()), new XAttribute("CategoryIds", XmlUtils.FilterHashData(WikiXML, wiki.Categories, "Categories", "Id")), new XAttribute("TagIds", XmlUtils.FilterHashData(WikiXML, wiki.Tags, "Tags", "Id")), new XElement("Title", wiki.Title), new XElement("Content", new XCData(wiki.Content)) ); WikiXML.Root.Element("WikiEntries").Add(wikiEntry); WikiXML.Save(XmlFilePath); }