List <Trainee> IDL.getTraineeList()
        {
            List <Trainee> traineeList = (from XElement traineeElement in TraineeRoot.Elements()
                                          select traineeElement.XmlToDOTrainee()).ToList();

            return(traineeList);
        }
        List <Trainee> IDL.getCertainTraineesList(Predicate <Trainee> pred)
        {
            List <Trainee> traineeList = (from XElement traineeElement in TraineeRoot.Elements()
                                          select traineeElement.XmlToDOTrainee()).ToList();
            List <Trainee> certainTraineesList = (from Trainee trainee in traineeList
                                                  where pred(trainee)
                                                  select trainee).ToList();

            return(certainTraineesList);
        }
        void IDL.removeTrainee(int id)
        {
            XElement traineeElement = (from trainee in TraineeRoot.Elements()
                                       where int.Parse(trainee.Element("ID").Value) == id
                                       select trainee).FirstOrDefault();

            if (traineeElement == null)
            {
                throw new TraineesIdNotFoundException(id);
            }
            traineeElement.Remove();
            TraineeRoot.Save(TraineePath);
        }
        void IDL.updateTrainee(int id, Trainee updatedTrainee)
        {
            XElement traineeElement = (from item in TraineeRoot.Elements()
                                       where int.Parse(item.Element("ID").Value) == id
                                       select item).FirstOrDefault();

            if (traineeElement == null)
            {
                throw new TraineesIdNotFoundException(id);
            }
            traineeElement.Remove();
            TraineeRoot.Add(updatedTrainee.ToXmlTrainee());
            TraineeRoot.Save(TraineePath);
        }
        Trainee IDL.getTrainee(int id)
        {
            //if (!TraineeRoot.Element("trainee").HasElements)
            //    throw new Exception("No Trainees in the dataSource");
            XElement foundTrainee = (from XElement traineeElement in TraineeRoot.Elements()
                                     where traineeElement.Element("ID").Value.Equals(id.ToString())
                                     select traineeElement).FirstOrDefault();

            if (foundTrainee == null)
            {
                throw new TraineesIdNotFoundException(id);
            }
            return(foundTrainee.XmlToDOTrainee());
        }
        void IDL.addTrainee(Trainee trainee)
        {
            int id = (from item in TraineeRoot.Elements()
                      where (int.Parse(item.Element("ID").Value) == trainee.ID)
                      select(int.Parse(item.Element("ID").Value))).FirstOrDefault();

            if (id != 0)
            {
                throw new TraineesIdAlreadyExistsException(trainee.ID, trainee.FirstName + " " + trainee.LastName);
            }

            TraineeRoot.Add(trainee.ToXmlTrainee());
            TraineeRoot.Save(TraineePath);
        }