public bool AddTester(Tester tester) { //if tester is to young if (DateTime.Now.Year - tester.DateOfBirth.Year < Configuration.minTesterAge) { throw new Exception("A tester cannot be under " + Configuration.minTesterAge + " years old /n"); } //if tester is to old if (DateTime.Now.Year - tester.DateOfBirth.Year > Configuration.MaxTesterAge) { throw new Exception("A tester cannot be over " + Configuration.minTesterAge + " years old /n"); } try { IDal _dal = FactorySingletonDal.GetDal(); if (_dal.AddTester(tester)) { return(true); } return(false); } catch (Exception e) { throw e; } }
/*Data Manipulations*/ //Data manipulations on TESTERS /// <summary> /// Adds a tester to the testers list in the Data Source /// </summary> /// <param name="tester">Tester to be added</param> public string AddTester(Tester tester) { string error = "Failed to add " + tester.GetName(); if (IsTesterIdFound(tester.Id) == true) { return("Id " + tester.Id + " was already found"); } else if (TesterPropertiesValidation(tester) == true) { error = m_xamlImp.AddTester(tester); } return(error); }
public void AddTester(Tester tester) { if (dal.FindTester(tester.Id) != null || dal.FindTrainee(tester.Id) != null) { throw new MyExceptions("תעודת זהות זו כבר קיימת במערכת"); } if (!CheckIdValidity(tester.Id)) { throw new MyExceptions("תעודת זהות לא תקינה"); } // if tester age < 40 - deny if (tester.Age < Configuration.TesterMinAge) { throw new MyExceptions("tester:" + tester.FullName + " is under 40 YO"); } else { dal.AddTester(tester); } }
public void AddTester(Tester tester) { if (!CheckIfIDisValid(tester.Id)) { throw new Exception(string.Format("id {0} is invalid israeli number. by the rules of ID numbers", tester.Id)); } if (dal.GetTesterByID(tester.Id) != null) { throw new Exception(String.Format("The tester {0} already exists", tester.ToString())); } float age = GetAgeByBirthday(tester.DateOfBirth); if (age > Configuration.MAX_TESTER_AGE) { throw new Exception(string.Format("Tester {0} is too old to be a tester. he {1} years old, and the the max age is {2}", tester.Id, age, Configuration.MAX_TESTER_AGE)); } if (age < Configuration.MIN_TESTER_AGE) { throw new Exception(string.Format("Tester {0} is too young to be a tester. he only {1} years old, and the the min age is {2}", tester.Id, age, Configuration.MIN_TESTER_AGE)); } dal.AddTester(tester); }
/// <summary> /// Add a Tester /// </summary> /// <param name="newTester">The Tester to add</param> public void AddTester(Tester newTester) { //check if tester is ok if (AllTesters.Any(tester => tester.Id == newTester.Id)) { throw new Exception("Tester exist already"); } if (Tools.GetAge(newTester.BirthDate) < Configuration.MinTesterAge) { throw new Exception("The Tester is too young"); } if (newTester.Address == null) { throw new Exception("Need to know tester address"); } if (newTester.BirthDate == DateTime.MinValue) { throw new Exception("Invalid birth date"); } //add tester _dalImp.AddTester(newTester); }