Example #1
0
        /// <summary>
        /// Добавить идею в файл идей
        /// </summary>
        /// <param name="idea"></param>
        public void AddIdea(Idea idea)
        {
            var XmlIdea = IdeaXmlPresenter.GetXmlByIdea(this.Doc.Doc, idea);

            this.Doc.Body.AppendChild(XmlIdea);
            this.Doc.Save();
        }
Example #2
0
        /// <summary>
        /// Изменяем данные идеи в документе
        /// </summary>
        public void ChangeIdea(Idea idea)
        {
            var xmlIdea = SearchIdeaXmlDocument(idea);

            //Если не нашли идею в документе, то создадим её и добавим в документ
            if (xmlIdea == null)
            {
                this.AddIdea(idea);
            }
            //Если нашли идею, то сделаем изменения
            else
            {
                IdeaXmlPresenter.ChangeDataInXmlIdea(ref xmlIdea, idea);
            }
            this.Doc.Save();
        }
Example #3
0
        /// <summary>
        /// Список всех идеи в документе
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, Idea> GetAllIdeas()
        {
            if (Doc?.Body == null)
            {
                return(null);
            }

            Dictionary <string, Idea> result = new Dictionary <string, Idea>();

            foreach (XmlElement node in this.Doc.Body.ChildNodes)
            {
                if (node.Name == "Idea")
                {
                    Idea curIdea = IdeaXmlPresenter.GetIdeaByXml(node);
                    if (curIdea != null)
                    {
                        result.Add(curIdea.Id, curIdea);
                    }
                }
            }

            return(result);
        }