public IEnumerable <Trainee> GetAllTrainee(Func <Trainee, bool> predicat = null) { LoadDataTrainee(); IEnumerable <Trainee> allTrainee = from TElement in TraineeRoot.Elements() select new Trainee() { TraineeId = TElement.Element("TraineeId").Value, TraineeFirstName = TElement.Element("TraineeFirstName").Value, TraineeLastName = TElement.Element("TraineeLastName").Value, TraineeGender = (Gender)Enum.Parse(typeof(Gender), TElement.Element("TraineeGender").Value), TraineePhoneNumber = TElement.Element("TraineePhoneNumber").Value, TraineeEmailAddress = TElement.Element("TraineeEmailAddress").Value, TraineeAddress = Address.Parse(TElement.Element("TraineeAddress").Value), TraineeDateOfBirth = DateTime.Parse(TElement.Element("TraineeDateOfBirth").Value), TraineeLearingCar = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TraineeLearingCar").Value), TraineeGearbox = (TypeOfGearbox)Enum.Parse(typeof(TypeOfGearbox), TElement.Element("TraineeGearbox").Value), TraineeNameOfSchool = TElement.Element("TraineeNameOfSchool").Value, TraineeNameOfTeacher = TElement.Element("TraineeNameOfTeacher").Value, TraineeNumOfDrivingLessons = int.Parse(TElement.Element("TraineeNumOfDrivingLessons").Value), TraineeHasGlasses = bool.Parse(TElement.Element("TraineeHasGlasses").Value), IfTraineePassedAnInternalTest = bool.Parse(TElement.Element("IfTraineePassedAnInternalTest").Value) }; if (predicat == null)//no condition { return(allTrainee); } else { return(allTrainee.Where(predicat)); } }
public IEnumerable <Tester> GetAllTesters(Func <Tester, bool> predicat = null) { LoadDataTester(); IEnumerable <Tester> allTester = from TElement in TesterRoot.Elements() select new Tester() { isActive = bool.Parse(TElement.Element("isActive").Value), TesterId = TElement.Element("TesterId").Value, TesterLastName = TElement.Element("TesterLastName").Value, TesterFirstName = TElement.Element("TesterFirstName").Value, TesterDateOfBirth = DateTime.Parse(TElement.Element("TesterDateOfBirth").Value), TesterFamilyStatus = (FamilyStatus)Enum.Parse(typeof(FamilyStatus), TElement.Element("TesterFamilyStatus").Value), TesterGender = (Gender)Enum.Parse(typeof(Gender), TElement.Element("TesterGender").Value), TesterHasGlasses = bool.Parse(TElement.Element("TesterHasGlasses").Value), TesterPhoneNumber = TElement.Element("TesterPhoneNumber").Value, TesterEmailAddress = TElement.Element("TesterEmailAddress").Value, TesterAddress = Address.Parse(TElement.Element("TesterAddress").Value), TesterYearsOfExperience = int.Parse(TElement.Element("TesterYearsOfExperience").Value), TesterMaxNumOfTestsPerWeek = int.Parse(TElement.Element("TesterMaxNumOfTestsPerWeek").Value), TesterSpecialization = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TesterSpecialization").Value), MaxiDistanceFromAddress = double.Parse(TElement.Element("MaxiDistanceFromAddress").Value), Help_Matrix = TElement.Element("MatrixTesterworkdays").Value, }; if (predicat == null)//no condition { return(allTester); } else { return(allTester.Where(predicat)); } }
public IEnumerable <Test> GetAllTest(Func <Test, bool> predicat = null) { LoadDataTest(); IEnumerable <Test> allTest = from TElement in TestRoot.Elements() select new Test() { TestNumber = int.Parse(TElement.Element("TestNumber").Value), TesterId = TElement.Element("TesterId").Value, TraineeId = TElement.Element("TraineeId").Value, DateTimeOfTest = DateTime.Parse(TElement.Element("DateTimeOfTest").Value), TestExitAddress = Address.Parse(TElement.Element("TestExitAddress").Value), TestCriterion = Criterion.Parse(TElement.Element("TestCriterion").Value), TestResult = (PassOrFail)Enum.Parse(typeof(PassOrFail), TElement.Element("TestResult").Value), TestTypeOfCar = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TestTypeOfCar").Value), TestTypeOfGearbox = (TypeOfGearbox)Enum.Parse(typeof(TypeOfGearbox), TElement.Element("TestTypeOfGearbox").Value), TesterNote = TElement.Element("TesterNote").Value, }; if (predicat == null)//no condition { return(allTest); } else { return(allTest.Where(predicat)); } }
public Tester GetTester(string id) { LoadDataTester(); Tester returnT = new Tester(); returnT = (from TElement in TesterRoot.Elements() where TElement.Element("TesterId").Value == id select new Tester { isActive = bool.Parse(TElement.Element("isActive").Value), TesterId = TElement.Element("TesterId").Value, TesterLastName = TElement.Element("TesterLastName").Value, TesterFirstName = TElement.Element("TesterFirstName").Value, TesterDateOfBirth = DateTime.Parse(TElement.Element("TesterDateOfBirth").Value), TesterFamilyStatus = (FamilyStatus)Enum.Parse(typeof(FamilyStatus), TElement.Element("TesterFamilyStatus").Value), TesterGender = (Gender)Enum.Parse(typeof(Gender), TElement.Element("TesterGender").Value), TesterHasGlasses = bool.Parse(TElement.Element("TesterHasGlasses").Value), TesterPhoneNumber = TElement.Element("TesterPhoneNumber").Value, TesterEmailAddress = TElement.Element("TesterEmailAddress").Value, TesterAddress = Address.Parse(TElement.Element("TesterAddress").Value), TesterYearsOfExperience = int.Parse(TElement.Element("TesterYearsOfExperience").Value), TesterMaxNumOfTestsPerWeek = int.Parse(TElement.Element("TesterMaxNumOfTestsPerWeek").Value), TesterSpecialization = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TesterSpecialization").Value), MaxiDistanceFromAddress = double.Parse(TElement.Element("MaxiDistanceFromAddress").Value), Help_Matrix = TElement.Element("MatrixTesterworkdays").Value, }).FirstOrDefault(); return(returnT); }
public Trainee GetTrainee(string id, TypeOfCar car) { LoadDataTrainee(); Trainee returnT = new Trainee(); returnT = (from TElement in TraineeRoot.Elements() where (TElement.Element("TraineeId").Value == id) && ((TypeOfCar)Enum.Parse(typeof(TypeOfCar), (TElement.Element("TraineeLearingCar").Value)) == car) select new Trainee { TraineeId = TElement.Element("TraineeId").Value, TraineeFirstName = TElement.Element("TraineeFirstName").Value, TraineeLastName = TElement.Element("TraineeLastName").Value, TraineeGender = (Gender)Enum.Parse(typeof(Gender), TElement.Element("TraineeGender").Value), TraineePhoneNumber = TElement.Element("TraineePhoneNumber").Value, TraineeEmailAddress = TElement.Element("TraineeEmailAddress").Value, TraineeAddress = Address.Parse(TElement.Element("TraineeAddress").Value), TraineeDateOfBirth = DateTime.Parse(TElement.Element("TraineeDateOfBirth").Value), TraineeLearingCar = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TraineeLearingCar").Value), TraineeGearbox = (TypeOfGearbox)Enum.Parse(typeof(TypeOfGearbox), TElement.Element("TraineeGearbox").Value), TraineeNameOfSchool = TElement.Element("TraineeNameOfSchool").Value, TraineeNameOfTeacher = TElement.Element("TraineeNameOfTeacher").Value, TraineeNumOfDrivingLessons = int.Parse(TElement.Element("TraineeNumOfDrivingLessons").Value), TraineeHasGlasses = bool.Parse(TElement.Element("TraineeHasGlasses").Value), IfTraineePassedAnInternalTest = bool.Parse(TElement.Element("IfTraineePassedAnInternalTest").Value) }).FirstOrDefault(); return(returnT); }
public Test GetTest(int testNum) { LoadDataTest(); Test returnT = new Test(); returnT = (from TElement in TestRoot.Elements() where int.Parse(TElement.Element("TestNumber").Value) == testNum select new Test { TestNumber = int.Parse(TElement.Element("TestNumber").Value), TestExitAddress = Address.Parse(TElement.Element("TestExitAddress").Value), TestCriterion = Criterion.Parse(TElement.Element("TestCriterion").Value), TesterId = TElement.Element("TesterId").Value, TraineeId = TElement.Element("TraineeId").Value, DateTimeOfTest = DateTime.Parse(TElement.Element("DateTimeOfTest").Value), TestResult = (PassOrFail)Enum.Parse(typeof(PassOrFail), TElement.Element("TestResult").Value), TestTypeOfCar = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TestTypeOfCar").Value), TestTypeOfGearbox = (TypeOfGearbox)Enum.Parse(typeof(TypeOfGearbox), TElement.Element("TestTypeOfGearbox").Value), TesterNote = TElement.Element("TesterNote").Value, }).FirstOrDefault(); return(returnT); }