Пример #1
0
        //--------------menage children--------------//

        /// <summary>
        /// adds a Child object to the list
        /// throw Exception if there a Child with the same id.
        /// </summary>
        /// <param name="child">a Child object to add</param>
        public void addChild(Child child)
        {
            if (DataSource.ChildrenList.Any(x => x.Id == child.Id))
            {
                throw new DALException("There is the same child id alredy");
            }
            DataSource.ChildrenList.Add(child.Clone());
        }
Пример #2
0
 public void AddChild(Child child)
 {
     if (IdCheck(child.ID))
     {
         throw new Exception("ID already exists...");
     }
     DS.DataSource.ChildrenList.Add(child.Clone());
 }
Пример #3
0
        //--------------menage children----------------//

        /// <summary>
        /// adds a child to the data base
        /// Exception:
        /// there is are the same Id in the data base.
        /// </summary>
        /// <param name="child">child object to add </param>
        public void addChild(Child child)
        {
            if (DataSourceXml.ChildRoot.Elements().Any(x => (Convert.ToInt32(x.Element("Id").Value)) == child.Id))
            {
                throw new DALException("There is the same child id alredy");
            }
            DataSourceXml.ChildRoot.Add(child.Clone().ChildToXML());
            DataSourceXml.saveChildren();
        }
Пример #4
0
        public void UpdateChild(Child child)
        {
            int index = DS.DataSource.ChildrenList.FindIndex(c => c.ID == child.ID);

            if (index == -1)
            {
                throw new Exception("No child with same id was found... ");
            }
            DataSource.ChildrenList[index] = child.Clone();
        }
Пример #5
0
 /// <summary>
 /// update one child
 /// replice the old child with updated child
 /// </summary>
 /// <param name="child">updated child object</param>
 public void updateChildDetails(Child child)
 {
     if (DataSource.ChildrenList.All(X => X.Id != child.Id))
     {
         throw new DALException("There is no child to update");
     }
     DataSource.ChildrenList = (from item in DataSource.ChildrenList
                                where item.Id != child.Id
                                select item).ToList();
     DataSource.ChildrenList.Add(child.Clone());
 }
Пример #6
0
        /* Child functions */

        /// <summary>
        /// add child to child's DB
        /// </summary>
        /// <param name="child">the child to add to ChildList</param>
        /// <remarks>
        /// if find the child on the list - this child already exsist throw exception
        /// </remarks>
        public void AddChild(Child child)
        {
            if (!FindChild(child))
            {
                ChildList().Add(child.Clone());
            }
            else
            {
                throw new DALException(child.FirstName + " already exsist", "Add child");
            }
        }
Пример #7
0
 public void AddChild(Child child)
 {
     if (FindChild(child.Id) != null) // Makes sure that the child not exist already
     {
         throw new Exception("ERROR: The child with id: " + child.Id + " already exist in the database !!!");
     }
     else // Adds the child to the list
     {
         Child newChild = child.Clone(); // Creates a new instance
         DataSourceList.ChildrenList.Add(newChild);
     }
 }
Пример #8
0
        public void UpdateChild(Child child)
        {
            // Finds in the list the index of the child to update
            int index = DataSourceList.ChildrenList.FindIndex(c => c.Id == child.Id);

            if (index == -1) // The child not exist
            {
                throw new Exception("ERROR: The child with id: " + child.Id + " not exist in the database !!!");
            }
            else // Apdating the child
            {
                Child newChild = child.Clone(); // Creates a new instance
                DataSourceList.ChildrenList[index] = newChild;
            }
        }