static void setadjacentStationsList(string path)
 {
     XMLTools.LoadListFromXMLElement(path);
     foreach (var item in ListAdjacentStations)
     {
         AddAdjacentStations(item);
     }
 }
 static void setlineTripList(string path)
 {
     XMLTools.LoadListFromXMLElement(path);
     foreach (var item in ListLinesTrip)
     {
         AddLineTrip(item);
     }
 }
        public static void AddLineTrip(DLAPI.DO.LineTrip _lineTrip)
        {
            XElement lineTripsRootElem = XMLTools.LoadListFromXMLElement(LinesTripPath);
            XElement lineTripToAdd     = (from lineTrip in lineTripsRootElem.Elements()
                                          where int.Parse(lineTrip.Element("LineID").Value) == _lineTrip.LineID && TimeSpan.ParseExact(lineTrip.Element("StartAt").Value, "hh\\:mm\\:ss", CultureInfo.InvariantCulture) == _lineTrip.StartAt &&
                                          bool.Parse(lineTrip.Element("Active").Value)
                                          select lineTrip).FirstOrDefault();

            if (lineTripToAdd != null)
            {
                throw new DO.BadLineTripException(_lineTrip.LineID, "LineTrip already exist");
            }
            XElement newLineTripToAdd = new XElement("LineTrip", new XElement("LineTripID", _lineTrip.LineTripID),
                                                     new XElement("LineID", _lineTrip.LineID),
                                                     new XElement("StartAt", _lineTrip.StartAt.ToString()),
                                                     new XElement("Active", _lineTrip.Active));

            lineTripsRootElem.Add(newLineTripToAdd);
            XMLTools.SaveListToXMLElement(lineTripsRootElem, LinesTripPath);
        }
        public static void AddAdjacentStations(DLAPI.DO.AdjacentStations _adjacentStations)
        {
            XElement adjacentStationsRootElem = XMLTools.LoadListFromXMLElement(AdjacentStationsPath);
            XElement adjacentStationToAdd     = (from addAdjacentStations in adjacentStationsRootElem.Elements()
                                                 where int.Parse(addAdjacentStations.Element("Station1").Value) == _adjacentStations.Station1 && int.Parse(addAdjacentStations.Element("Station2").Value) == _adjacentStations.Station2 &&
                                                 bool.Parse(addAdjacentStations.Element("Active").Value)
                                                 select addAdjacentStations).FirstOrDefault();

            if (adjacentStationToAdd != null)
            {
                throw new DO.BadAdjacentStationsException(_adjacentStations.Station1, _adjacentStations.Station2, "LineTrip already exist");
            }
            XElement newAdjacentStationsAdd = new XElement("AdjacentStations", new XElement("Station1", _adjacentStations.Station1),
                                                           new XElement("Station2", _adjacentStations.Station2),
                                                           new XElement("Distance", _adjacentStations.Distance),
                                                           new XElement("Time", _adjacentStations.Time.ToString()),
                                                           new XElement("Active", _adjacentStations.Active));

            adjacentStationsRootElem.Add(newAdjacentStationsAdd);
            XMLTools.SaveListToXMLElement(adjacentStationsRootElem, AdjacentStationsPath);
        }