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; } }
public bool AddDrivingTest(Test test) { Trainee helpTrainee = GetTrainees().FirstOrDefault(t => t.ID == test.TraineeID); Tester helpTester = GetTesters().FirstOrDefault(t => t.ID == test.TesterID); //get all trainee tests. the last test will be first; var TraineeTests = ((from t in GetTests() where t.TraineeID == test.TraineeID select t).OrderByDescending(t => test.TestDay.Year) .ThenByDescending(t => test.TestDay.Month) .ThenByDescending(t => test.TestDay.Day).ToList()); //check there is enough days between tests if (TraineeTests.Any()) { TimeSpan ts = test.TestDay - TraineeTests.First().TestDay; if (ts.Days < Configuration.daysBetweenTests) { throw new Exception("There must be at least " + Configuration.daysBetweenTests + " days before a trainee can take another test\n"); } } //check trainee took enough lessons if (helpTrainee.NumOfLessons < Configuration.minLessons) { throw new Exception("A trainee cannot take a test if he took less than" + Configuration.minLessons + " lessons\n"); } //find all tests trainee succedded var licence = from t in GetTests() where t.TraineeID == test.TraineeID && t.TestResult == true select t; //check if trainee already have a licence to this type of car foreach (var item in licence) { if (item.Vehicle == test.Vehicle) { throw new Exception("Trainee already has licence for this type of car"); } } try { IDal _dal = FactorySingletonDal.GetDal(); if (_dal.AddDrivingTest(test)) { helpTester.NumOfTests++; helpTrainee.NumOfTests++; return(true); } return(false); } catch (Exception e) { throw e; } }
public bool UpdateTrainee(Trainee trainee) { try { IDal _dal = FactorySingletonDal.GetDal(); _dal.UpdateTrainee(trainee); } catch (Exception e) { throw e; } return(true); }
public bool UpdateTester(Tester tester) { try { IDal _dal = FactorySingletonDal.GetDal(); _dal.UpdateTester(tester); } catch (Exception e) { throw e; } return(true); }
public bool UpdateDrivingTest(Test test) { try { IDal _dal = FactorySingletonDal.GetDal(); _dal.UpdateDrivingTest(test); return(true); } catch (Exception e) { throw e; } }
public bool RemoveTester(string testerID) { try { IDal _dal = FactorySingletonDal.GetDal(); _dal.RemoveTester(testerID); } catch (Exception e) { throw e; } return(true); }
public bool RemovedrivingTest(int serialNumber) { try { IDal _dal = FactorySingletonDal.GetDal(); if (_dal.RemovedrivingTest(serialNumber)) { return(true); } return(false); } catch (Exception e) { throw e; } }
public bool RemoveTrainee(string traineeID) { IDal _dal = FactorySingletonDal.GetDal(); try { if (_dal.RemoveTrainee(traineeID)) { return(true); } return(false); } catch (Exception e) { throw e; } }
public bool AddTrainee(Trainee trainee) { //if trainee is to young if (DateTime.Now.Year - trainee.DateOfBirth.Year < Configuration.minTraineeAge) { throw new Exception("A trainee cannot be under " + Configuration.minTraineeAge + " years old \n"); } try { IDal _dal = FactorySingletonDal.GetDal(); if (_dal.AddTrainee(trainee)) { return(true); } return(false); } catch (Exception e) { throw e; } }
public List <Trainee> GetTrainees(Predicate <Trainee> predicate = null) { IDal _dal = FactorySingletonDal.GetDal(); return(_dal.GetTrainees(predicate)); }
public List <Test> GetTests(Predicate <Test> predicate = null) { IDal _dal = FactorySingletonDal.GetDal(); return(_dal.GetTests(predicate)); }
public Bl_imp() { dal = FactorySingletonDal.GetDal(); }