Exemplo n.º 1
0
        public void AddNanny(BE.Nanny nanny)

        {
            if (WhatAge(nanny.NannyBirth) < 18)
            {
                throw new Exception("canot add young nanny");
            }
            else
            {
                dimp.AddNanny(nanny);
            }
        }
Exemplo n.º 2
0
        DAL.Idal myIdal = DAL.FactoryDal.GetDal(); // get the dal type

        #region Nanny function

        /// <summary>
        /// add nanny if she inder 18 years old
        /// </summary>
        /// <param name="myNanny"></param>
        public void AddNanny(Nanny myNanny)
        {
            DateTime date    = myNanny.DateOfBirth;
            DateTime ourTime = DateTime.Now.AddYears(-18);
            int      comp    = date.CompareTo(ourTime);

            if (comp <= 0) // nanny more then 18 years
            {
                myIdal.AddNanny(myNanny);
                return;
            }
            throw new Exception("Nanny under 18 years !!");
        }
Exemplo n.º 3
0
        /// <summary>
        /// cheaking if nanny age more then 18 years
        /// </summary>
        /// <param name="nanny">Nanny</param>
        public void AddNanny(Nanny nanny)
        {
            DateTime today = DateTime.Today;
            int      Age   = today.Year - nanny.NannyDate.Year;

            if (Age >= 18)
            {
                dal.AddNanny(nanny);
            }
            else
            {
                throw new Exception("This nanny is too young");
            }
        }