Exemplo n.º 1
0
        /// <summary>
        /// update mothers info in list
        /// </summary>
        /// <param name="mother"></param>
        public void updateMother(Mother mother)
        {
            XElement motherElement = (from m in DataSourceXml.Mothers.Elements()
                                      where Convert.ToInt32(m.Element("id").Value) == mother.id
                                      select m).FirstOrDefault();

            if (motherElement != null)
            {
                motherElement.ReplaceWith(mother.toXML());
                DataSourceXml.SaveMothers();
            }
            else
            {
                throw new Exception("the mother is not in the system.\n");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// adds a mother to list
        /// </summary>
        /// <param name="mother"></param>
        public void addMother(Mother mother)
        {
            var temp = (from m in DataSourceXml.Mothers.Elements()
                        where Convert.ToInt32(m.Element("id").Value) == mother.id
                        select m).FirstOrDefault();

            if (temp == null)
            {
                DataSourceXml.Mothers.Add(mother.toXML());
                DataSourceXml.SaveMothers();
            }
            else
            {
                throw new Exception("you are trying to add a existing mother.\n");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// deletes mother from list
        /// </summary>
        /// <param name="mother"></param>
        public void deleteMother(Mother mother)
        {
            XElement motherElement = (from n in DataSourceXml.Mothers.Elements()
                                      where Convert.ToInt32(n.Element("id").Value) == mother.id
                                      select n).FirstOrDefault();

            if (motherElement != null)
            {
                motherElement.Remove();
                DataSourceXml.SaveMothers();
            }
            else
            {
                throw new Exception("you are trying to delete a mother that does not exist\n");
            }
        }