/// <summary> /// adds a trainee and confime that it can be added /// </summary> /// <param name="t">trainee to add</param> /// /// <param name="Age">how old he is</param> public void AddTrainee(Trainee t) { TimeSpan Age = DateTime.Now - t.traineeBirthDate; if (t.traineeId.Length != 9) { throw new Exception("ID must have 9 digits"); } if (t.traineeName == "") { throw new Exception("You must enter a trainee's first name"); } if (t.traineeLast == "") { throw new Exception("You must enter a trainee's last name"); } if (t.traineeBirthDate == null) { throw new Exception("You must enter the birth date of the trainee"); } if (t.traineeBirthDate > DateTime.Now) { throw new Exception("Birth date cannot be in the furture"); } if ((Age.TotalDays / 365) >= Configuration.MinAgeOfTrainee) { try { dal.AddTrainee(t); } catch (Exception e) { throw e; } } else { throw new Exception("You are too young to be a Trainee"); } }