Example #1
0
        public bool AddDrivingTest(DrivingTest drivingTest)
        {
            //האם הנבחן קיים במערכת
            Trainee currentTrainee = findTrainee(drivingTest.Trainee_ID);

            // עדכון פרטי הטסט
            drivingTest.carType       = currentTrainee.CarTrained;
            drivingTest.StartingPoint = currentTrainee.Address.Clone();
            //עשה מספיק שיעורים
            if (currentTrainee.LessonsNb < Configuration.MIN_LESSONS_TO_REGISTER)
            {
                throw new Exception("The trainee has not yet had 20 lessons");
            }
            //בודק האם ישנם טסטים בעבר שעבר או שקיים לו כבר טסט עתידי או שהאחרון היה לפני פחות משבוע
            if (numOfTests(currentTrainee) > 0)
            {
                TestsInThePast(currentTrainee);
            }
            //האם יש בוחן זמין
            Tester currentTester = findTester(drivingTest.Tester_ID);

            if (currentTester == null)
            {
                throw new Exception("There are no free tasters for this hour. Please create a new test for a different time");
            }

            drivingTest.Tester_ID = currentTester.ID;

            //ADD
            try
            {
                dal.AddDrivingTest(drivingTest);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(true);
        }