public void AddContract(Contract contract) { Nanny nanny = GetNanny(contract.NannyId); Child child = GetChild(contract.ChildId); Mother mother = GetMother((child.MotherID)); if (!BL_Tool.IsChildOver3Month(child)) { throw new Exception("Child is too young..."); } int ammountOfContracts = BL_Tool.GetNumberOfContractsByCondition(n => n.NannyId == nanny.ID); if (ammountOfContracts >= nanny.KidsCapacity) { throw new Exception("Nanny is full..."); } if (!BL_Tool.CheckAgeIsInRange(nanny, child)) { throw new Exception("Child's age is not within the nanny's age range..."); } var contracts = GetContracts(c => c.ChildId == child.ID); foreach (var item in contracts) { if (BL_Tool.OverlappingTime(nanny, GetNanny(item.NannyId))) { throw new Exception($"Warning:{child.Name} is already registered in those hours"); } } contract.Signed = true; dal.AddContract(contract); }