/// <summary>
        /// adds a new test to the list if the student already took the last test more than a week ago or did not tested yet
        /// </summary>
        /// <param name="t">a test to add</param>
        public void AddTest(Test t)
        {
            foreach (Trainee trainee2 in dal.GetTrainees())
            {
                if (trainee2.traineeId == t.TraineeId)
                {
                    if (trainee2.traineeLessons < Configuration.MinNumOfLessons)
                    {
                        throw new Exception("You did not do enough lessons");
                    }
                }
            }
            foreach (Tester tester2 in dal.GetTesters())
            {
                if (tester2.testerId == t.TesterId)
                {
                    int amount = 0;
                    for (int i = 0; i < 5; i++)
                    {
                        for (int k = 0; k < 7; k++)
                        {
                            if (tester2.testerWorkHours[i, k] == true)
                            {
                                amount++;
                            }
                        }
                    }
                    if (amount >= tester2.testerMaxTests)
                    {
                        throw new Exception("Tester reached the maximum amount of tests this week." + '\n' +
                                            "You cannot take the test with this tester");
                    }
                }
                else
                {
                    throw new Exception("Tester does not exsist");
                }
            }

            bool flag = false;
            Test temp = t;

            //int min = t.traineeId;
            foreach (Test oldTest in dal.GetTests())
            {
                if (t.TraineeId == oldTest.TraineeId)
                {//if he took a test before
                    flag = true;
                    if (oldTest.Datetime > t.Datetime)
                    {
                        temp = oldTest;
                    }
                }
            }
            if (flag)
            {                                                                                      //if got into the previous if so:
                if (temp.Datetime.AddDays(Configuration.MinAmountOfTimeBetweenTests) > t.Datetime) //if the last test's date + 7 days is bigger than the new test to add date it means that 7 days have not passed yet
                {
                    throw new Exception("Cannot do 2 tests in less than 7 days");
                }
            }

            if ((t.Datetime.Year == DateTime.Now.Year) && (t.Datetime.Month == DateTime.Now.Month) && (int)((t.Datetime - DateTime.Now).Days) <= 7) // possibility to set a test for week ahead
            {
                //allows to add a test only if it is in the week that we are at

                var v = from item in dal.GetTesters() // v is a list of testers that are avaliable at the time that the trainee asked for
                        where (item.testerId == t.TesterId && item.testerWorkHours[(int)(t.Datetime.DayOfWeek), (t.Hour - 9)].Equals(true))
                        select item;
                if (v == null)
                {
                    throw new Exception("Tester is unavaliable at this hour");
                }
            }
            else
            {
                throw new Exception("You cannot save a date for the test more than a week before the date you want");
            }
            foreach (Test tl in dal.GetTests())
            {
                if (tl.TraineeId == t.TraineeId && tl.Grade == true && tl.TOfCar == t.TOfCar)
                {
                    throw new Exception("You cannot take a test on this type of viecle because you have passed");
                }
            }
            var tester = from item in dal.GetTesters()
                         where (item.testerId == t.TesterId)
                         select item;
            var trainee = from item in dal.GetTrainees()
                          where (item.traineeId == t.TraineeId)
                          select item;

            if (((Tester)tester).testerProfession != ((Trainee)trainee).traineeViecle)
            {
                throw new Exception("The tester profession does not fit the trainee's type of car");
            }

            try { dal.AddTest(t); }

            catch (Exception e) { throw e; }
        }