private bool saveOrUpdateArticle(Articles.Article source) { var sw = new Performance.Stopwatch("saveOrUpdateArticle"); sw.Start(); if (!ArticleDB.AncestorsAndSelf("Articles").Any()) ArticleDB.Add(new XElement("Articles")); if (ArticleDB.Elements("Article").Any(x => x.Element("ArticleID").Value == source.ArticleID)) ArticleDB.Elements("Article").Single(x => x.Element("ArticleID").Value == source.ArticleID).ReplaceWith(source.GetXElement()); else ArticleDB.Add(source.GetXElement()); try { File.WriteAllText(DatabasePath + CurrentCompany.CompanyID + "\\Articles.xml", ArticleDB.ToString()); } catch (Exception e) { logger.Fatal("Error writing article to " + DatabasePath + CurrentCompany.CompanyID + "\\Articles.xml", e); return false; } sw.Stop(); logger.Info(sw.Result()); return true; }