Пример #1
0
        /// <summary>
        /// Add a contract to the contract list
        /// </summary>
        /// <param name="m">The contract you want to add to the contract list</param>
        public void AddContract(Contract c)
        {
            if (DateTime.Today < GetChild(c.ChildID).Birthdate.AddMonths(3))
            {
                throw new Exception("The kid is younger than 3 monthes");
            }

            //Checks if there is a place for another child to this nanny
            int numChildsToNanny = 0;

            foreach (var con in GetContractsByTerm(con => con.NannyID == c.NannyID && con.WasSignature))
            {
                numChildsToNanny++;
            }

            if (numChildsToNanny < GetNanny(c.NannyID).MaxChilds)
            {
                c.WasSignature = true;
            }
            else
            {
                c.WasSignature = false;
            }

            dal.AddContract(c);
            RepairWageForMotherAndNanny(GetMother(c.MotherID), GetNanny(c.NannyID));
        }