public void AddContract(Contract inputContract) { Nanny nanny = DalTools.GetNanny(inputContract.NannyID); Child child = DalTools.GetChild(inputContract.ChildID); //cheak if the age of the infant is under 3 month DateTime age = (DalTools.GetChild(inputContract.ChildID)).ChildAge; age.AddMonths(3); if (DateTime.Now < age) { throw new Exception("Can't add Child to Contract under 3 months"); } //checks if nanny capacity is full if (nanny.IsNannyCapacityIsFull()) { throw new Exception("Nanny hace reached the maximum infants capacity..."); } //checks if child age is not over the maximum/minimum nanny accepts int childAgeInMonths = child.AgeInMonths(); if (childAgeInMonths < nanny.NannyMinInfantAge || childAgeInMonths > nanny.NannyMaxInfantAge) { throw new Exception("Nanny can't accept this age"); } if (inputContract.IsContractSigned) { //checks if contract salary calculated by month or by hour and updates the salary nanny if (inputContract.PaymentMethod == Payment_method.hourly) { inputContract.HourlySalary = BlTools.CalculateHourlySalary(nanny, child); } else { inputContract.MonthlySalary = BlTools.CalculateMonthlySalary(nanny, child); } } BlTools.GetChild(inputContract.ChildID).IsHaveNanny = true; dal.AddContract(inputContract); }