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); }
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); }