Exemplo n.º 1
0
        /// <summary>
        /// removes child from list
        /// </summary>
        /// <param name="child"></param>
        public void deleteChild(Child child)
        {
            XElement childElement = (from n in DataSourceXml.Children.Elements()
                                     where Convert.ToInt32(n.Element("id").Value) == child.id
                                     select n).FirstOrDefault();

            if (childElement != null)
            {
                childElement.Remove();
                DataSourceXml.SaveChildren();
            }
            else
            {
                throw new Exception("child is not in the system\n");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// updates child info
        /// </summary>
        /// <param name="child"></param>
        public void updateChild(Child child)
        {
            XElement childElement = (from c in DataSourceXml.Children.Elements()
                                     where Convert.ToInt32(c.Element("id").Value) == child.id
                                     select c).FirstOrDefault();

            if (childElement != null)
            {
                childElement.ReplaceWith(child.toXML());
                DataSourceXml.SaveChildren();
            }
            else
            {
                throw new Exception("the child is not in the system.\n");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// adds child to list
        /// </summary>
        /// <param name="child"></param>
        public void addChild(Child child)
        {
            var temp = (from c in DataSourceXml.Children.Elements()
                        where Convert.ToInt32(c.Element("id").Value) == child.id
                        select c).FirstOrDefault();

            if (temp == null)
            {
                DataSourceXml.Children.Add(child.toXML());
                DataSourceXml.SaveChildren();
            }
            else
            {
                throw new Exception("you are trying to add a existing child.\n");
            }
        }