Ejemplo n.º 1
0
        } //v

        public bool AddTester(Tester tester)
        {
            if (DateTime.Now.Year - tester.DayOfBirth.Year < Configuration.MIN_TESTER_AGE)
            {
                throw new Exception("tester under " + Configuration.MIN_TESTER_AGE + " years");
            }
            try
            {
                dal.AddTester(tester);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(true);
        } //v
Ejemplo n.º 2
0
 /// <summary>
 /// the function checks the logic of a tester before adding or updating him to the database
 /// </summary>
 /// <param name="tester"></param>
 /// <param name="update"></param>
 public void AddTester(Tester tester, bool update = false)
 {
     if (!update && dal.GetTesters().Any(T => T.Equals(tester)))
     {
         throw new InvalidOperationException("A tester with that ID already exists");
     }
     if (!update && dal.GetTrainees().Any(T => T.Equals(tester)))
     {
         throw new InvalidOperationException("A trainee with that ID exists");
     }
     if (tester.Age < Configuration.MinAgeOfTester)
     {
         throw new InvalidOperationException("The tester is younger than " + Configuration.MinAgeOfTester);
     }
     dal.AddTester(tester);
 }
Ejemplo n.º 3
0
 public bool AddTester(Tester tester)
 {
     if (DateTime.Now.Year - tester.DayOfBirth.Year < 40)
     {
         throw new Exception("tester under 40 years");
         //  return false;
     }
     try
     {
         dal.AddTester(tester);
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return(true);
 }