Ejemplo n.º 1
0
        //---------------menage mother----------------//

        /// <summary>
        /// adds a Mother object to the list
        /// throw Exception if there a mother with the same id.
        /// </summary>
        /// <param name="mam">mother object to add</param>
        public void addMother(Mother mam)
        {
            if (DataSource.MotherList.Any(x => x.Id == mam.Id))
            {
                throw new DALException("There is the same mother id already");
            }
            DataSource.MotherList.Add(mam.Clone());
        }
Ejemplo n.º 2
0
 public void AddMother(Mother mother)
 {
     if (IdCheck(mother.ID))
     {
         throw new Exception("ID already exists...");
     }
     DS.DataSource.MotherList.Add(mother.Clone());
 }
Ejemplo n.º 3
0
        public Person Clone()
        {
            var copy = (Person)MemberwiseClone();

            copy.Father = Father?.Clone();
            copy.Mother = Mother?.Clone();
            return(copy);
        }
Ejemplo n.º 4
0
        public object Clone()
        {
            var person = (Person)ShallowClone();

            person.IdInfo = (IdInfo)IdInfo?.Clone();
            person.Mother = (Person)Mother?.Clone();
            person.Kids   = Kids.Select(x => x.Clone()).Cast <Person>().ToList();
            return(person);
        }
Ejemplo n.º 5
0
        public void UpdateMother(Mother mother)
        {
            int index = DS.DataSource.MotherList.FindIndex(x => x.ID == mother.ID);

            if (index == -1)
            {
                throw new Exception("No mother with same id was found... ");
            }
            DataSource.MotherList[index] = mother.Clone();
        }
Ejemplo n.º 6
0
 public void updateMotherDetalse(Mother mam)
 {
     try
     {
         dl.updateMotherDetalse(mam.Clone());
     }
     catch (DALException exception)
     {
         throw new BLException(exception.Message);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// adds a new mother to the list of mothers
 /// </summary>
 /// <param name="mam">a Mother item</param>
 public void addMother(Mother mam)
 {
     try
     {
         dl.addMother(mam.Clone());
     }
     catch (DALException exception)
     {
         throw new BLException(exception.Message);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// update one mother
 /// replice the old mother with updated mother
 /// </summary>
 /// <param name="mam">updated mother object</param>
 public void updateMotherDetalse(Mother mam)
 {
     if (DataSource.MotherList.All(X => X.Id != mam.Id))
     {
         throw new DALException("There is no Mother to update");
     }
     DataSource.MotherList = (from item in DataSource.MotherList
                              where item.Id != mam.Id
                              select item).ToList();
     DataSource.MotherList.Add(mam.Clone());
 }
Ejemplo n.º 9
0
 /// <summary>
 /// update mother
 /// </summary>
 /// <param name="mother">the new mother that replace the old mother</param>
 /// <remarks>
 /// accept mother and cal dal.UpdateMother
 /// </remarks>
 public void UpdateMother(Mother mother)
 {
     try
     {
         dal.UpdateMother(mother.Clone());
     }
     catch (DALException ex)
     {
         throw new BLException(ex.Message, ex.sender);
     }
 }
Ejemplo n.º 10
0
        /* mother functions */

        /// <summary>
        /// add mother to mother's DB
        /// </summary>
        /// <param name="mother">the mother to add to MotherList</param>
        /// <remarks>
        /// if find the mother on the list - this nanny already exsist throw exception
        /// </remarks>
        public void AddMother(Mother mother)
        {
            if (!FindMother(mother))
            {
                MotherList().Add(mother.Clone());
            }
            else
            {
                throw new DALException(mother.FullName() + " already exsist", "Add mother");
            }
        }
Ejemplo n.º 11
0
 public void AddMother(Mother mother)
 {
     if (FindMother(mother.Id) != null) // Makes sure that the mother not exist already
     {
         throw new Exception("ERROR: The mother with id: " + mother.Id + " already exist in the database !!!");
     }
     else // Adds the mother to the list
     {
         Mother newMother = mother.Clone(); // Creates a new instance
         DataSourceList.MothersList.Add(newMother);
     }
 }
Ejemplo n.º 12
0
        public void UpdateMother(Mother mother)
        {
            // Finds in the list the index of the mother to update
            int index = DataSourceList.MothersList.FindIndex(m => m.Id == mother.Id);

            if (index == -1) // The mother was not exist
            {
                throw new Exception("ERROR: The mother with id: " + mother.Id + " not exist in the database !!!");
            }
            else // Apdating the mother
            {
                Mother newMother = mother.Clone(); // Creates a new instance
                DataSourceList.MothersList[index] = newMother;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// find mother with givan ID
        /// </summary>
        /// <param name="id">>the mother's id that we whant to find</param>
        /// <remarks>
        /// accept mother and cal dal.FindMother(int?? id)
        /// retrun mother if find, else return null
        /// </remarks>
        public Mother FindMother(int?id)
        {
            Mother mother = dal.FindMother(id);

            return(mother == null ? null : mother.Clone());
        }
Ejemplo n.º 14
0
 /// <summary>
 /// find mother
 /// </summary>
 /// <param name="mother">the mother that we whant to find</param>
 /// <remarks>
 /// accept mother and cal dal.FindMother(Mother mother)
 /// retrun true if find, else return false
 /// </remarks>
 public bool FindMother(Mother mother)
 {
     return(dal.FindMother(mother.Clone()));
 }