Example #1
0
        //------------menage nanny--------------//

        /// <summary>
        /// adds a Nanny object to the list
        /// throw Exception if there a Nanny with the same id.
        /// </summary>
        /// <param name="nen">a Nanny object to add</param>
        public void addNanny(Nanny nen)
        {
            if (DataSource.NannyList.Any(x => x.Id == nen.Id))
            {
                throw new DALException("There is the same nanny already");
            }
            DataSource.NannyList.Add(nen.Clone());
        }
Example #2
0
 public void AddNanny(Nanny nanny)
 {
     if (IdCheck(nanny.ID))
     {
         throw new Exception("ID already exists...");
     }
     DS.DataSource.NannyList.Add(nanny.Clone());
 }
Example #3
0
        public void UpdateNanny(Nanny nanny)
        {
            int index = DS.DataSource.NannyList.FindIndex(x => x.ID == nanny.ID);

            if (index == -1)
            {
                throw new Exception("No Nanny with same id was found... ");
            }
            DataSource.NannyList[index] = nanny.Clone();
        }
Example #4
0
 /// <summary>
 /// update a one nanny
 ///
 /// replice the old nanny with updated nanny
 /// </summary>
 /// <param name="nan">updeted nanny object</param>
 public void updateNannyDetails(Nanny nan)
 {
     if (DataSource.NannyList.All(X => X.Id != nan.Id))
     {
         throw new DALException("There is no nanny to update");
     }
     DataSource.NannyList = (from item in DataSource.NannyList
                             where item.Id != nan.Id
                             select item).ToList();
     DataSource.NannyList.Add(nan.Clone());
 }
Example #5
0
 /// <summary>
 /// update nanny
 /// </summary>
 /// <param name="nanny">the new Nanny that replace the old nanny</param>
 /// <remarks>
 /// accept nanny and cal dal.UpdateNanny
 /// </remarks>
 public void UpdateNanny(Nanny nanny)
 {
     try
     {
         dal.UpdateNanny(nanny.Clone());
     }
     catch (DALException ex)
     {
         throw new BLException(ex.Message, ex.sender);
     }
 }
Example #6
0
        /* Nanny functions */

        /// <summary>
        /// add nanny to nanny's DB
        /// </summary>
        /// <param name="nanny">the nanny to add to NannyList</param>
        /// <remarks> if find the nanny on the list -
        /// meeans this nanny already exsist throw exception </remarks>
        public void AddNanny(Nanny nanny)
        {
            if (!FindNanny(nanny))
            {
                NannyList().Add(nanny.Clone());
            }
            else
            {
                throw new DALException(nanny.FullName() + " already exsist", "Add nanny");
            }
        }
Example #7
0
 public void AddNanny(Nanny nanny)
 {
     if (FindNanny(nanny.Id) != null) // Makes sure that the nanny not exist already
     {
         throw new Exception("ERROR: The nanny with id: " + nanny.Id + " already exist in the database !!!");
     }
     else // Adds the nanny to the list
     {
         Nanny newNanny = nanny.Clone(); // Creates a new instance
         DataSourceList.NanniesList.Add(newNanny);
     }
 }
Example #8
0
        public void UpdateNanny(Nanny nanny)
        {
            // Finds in the list the index of the nanny to update
            int index = DataSourceList.NanniesList.FindIndex(n => n.Id == nanny.Id);

            if (index == -1) // The nanny was not exist
            {
                throw new Exception("ERROR: The nanny with id: " + nanny.Id + " not exist in the database !!!");
            }
            else // Apdating the nanny
            {
                Nanny newNanny = nanny.Clone(); // Creates a new instance
                DataSourceList.NanniesList[index] = newNanny;
            }
        }
Example #9
0
 public void updateNannyDetails(Nanny nan)
 {
     try
     {
         TimeSpan minAge = new TimeSpan(365 * 18);
         if (DateTime.Now - nan.BirthDate < minAge)
         {
             throw new BLException("The age of Nanny is not ligal");
         }
         dl.updateNannyDetails(nan.Clone());
     }
     catch (DALException exception)
     {
         throw new BLException(exception.Message);
     }
 }
Example #10
0
 /// <summary>
 /// adds a new nanny to the list of nannis
 /// </summary>
 /// <param name="nan">a Nenny item</param>
 public void addNanny(Nanny nan)
 {
     try
     {
         TimeSpan minAge = new TimeSpan(365 * 18);
         if (DateTime.Now - nan.BirthDate < minAge)
         {
             throw new Exception();
         }
         dl.addNanny(nan.Clone());
     }
     catch (DALException excption)
     {
         throw new BLException(excption.Message);
     }
 }
Example #11
0
        //--------------menage nannis----------------//

        /// <summary>
        /// adds a nanny to the data base
        /// Exception:
        /// in the data base is are a nanny with the same ID
        /// </summary>
        /// <param name="nan">nanny object to add</param>
        public void addNanny(Nanny nan)
        {
            var check = (from nanny in DataSourceXml.NannyRoot.Elements()
                         where (Convert.ToInt32(nanny.Element("Id").Value)) == nan.Id
                         select nanny).FirstOrDefault();

            if (check == null)
            {
                DataSourceXml.NannyRoot.Add(nan.Clone().NannyToXml());
                DataSourceXml.saveNannis();
            }
            else
            {
                throw new Exception("There is the same nanny already");
            }
        }
Example #12
0
        /* Nanny functions */

        /// <summary>
        /// add Nanny to nanny's DB
        /// </summary>
        /// <param name="nanny">the nanny to add to NannyList</param>
        /// <remarks>
        /// if nany age is under 18 throw exception
        /// cal dal.addNanny
        /// </remarks>
        public void AddNanny(Nanny nanny)
        {
            if (nanny.NannyAge < 18 || nanny.NannyAge == null)
            {
                throw new BLException(nanny.FullName() + " age is under 18", "add nanny");
            }
            try
            {
                Valid(nanny);
            }
            catch (BLException)
            {
                throw;
            }
            try
            {
                dal.AddNanny(nanny.Clone());
            }
            catch (DALException ex)
            {
                throw new BLException(ex.Message, ex.sender);
            }
        }
Example #13
0
        /// <summary>
        /// find nanny with given ID
        /// </summary>
        /// <param name="id">the nanny's id that we whant to find</param>
        /// <remarks>
        /// accept nanny and cal dal.FindNanny(int?? id)
        /// retrun nanny if find, else return null
        /// </remarks>
        public Nanny FindNanny(int?id)
        {
            Nanny nanny = dal.FindNanny(id);

            return(nanny == null ? null : nanny.Clone());
        }
Example #14
0
 /// <summary>
 /// find nanny
 /// </summary>
 /// <param name="nanny">the nanny that we whant to find</param>
 /// <remarks>
 /// accept nanny and cal dal.FindNanny(Nanny nanny)
 /// retrun true if find, else return false
 /// </remarks>
 public bool FindNanny(Nanny nanny)
 {
     return(dal.FindNanny(nanny.Clone()));
 }