//CRUD
 #region AdjacentStation
 public void AddAdjacentStation(AdjacentStation adjacentStation)//IDL function
 {
     if (DataSource.AdjacentStations.FirstOrDefault(stations => stations.Station1 == adjacentStation.Station1 && stations.Station2 == adjacentStation.Station2 && !stations.Deleted) == null)
     {
         DataSource.AdjacentStations.Add(adjacentStation.Clone());
     }
 }
        public void DeleteAdjacentStation(int station1, int station2)//IDL function
        {
            AdjacentStation cur = DataSource.AdjacentStations.FirstOrDefault(stations => ((stations.Station1 == station1 && stations.Station2 == station2) || (stations.Station1 == station2 && stations.Station2 == station1)) && !stations.Deleted);

            if (cur == null)
            {
                throw new AdjacentStationExceptions(station1, station2, false);
            }
            cur.Deleted = true;
        }
        public void UpdateAdjacentStation(AdjacentStation newAdjacentStation)//IDL function
        {
            AdjacentStation cur = DataSource.AdjacentStations.FirstOrDefault(stations => (stations.Station1 == newAdjacentStation.Station1 && stations.Station2 == newAdjacentStation.Station2) || (stations.Station1 == newAdjacentStation.Station2 && stations.Station2 == newAdjacentStation.Station1) && !stations.Deleted);

            if (cur == null)
            {
                throw new AdjacentStationExceptions(newAdjacentStation.Station1, newAdjacentStation.Station2, false);
            }
            DataSource.AdjacentStations.Remove(cur);
            DataSource.AdjacentStations.Add(newAdjacentStation.Clone());
        }
        public AdjacentStation GetAdjacentStation(int station1, int station2)//IDL function
        {
            AdjacentStation retValue = DataSource.AdjacentStations.FirstOrDefault(stations => (stations.Station1 == station1 && stations.Station2 == station2) || (stations.Station1 == station2 && stations.Station2 == station1) && !stations.Deleted);

            if (retValue != null)
            {
                return(retValue.Clone());
            }
            else
            {
                throw new AdjacentStationExceptions(station1, station2, false);
            }
        }
Exemplo n.º 5
0
        public AddAdj(IEnumerable <BO.AdjacentStation> exists, int?code = null)
        {
            InitializeComponent();
            if (code != null)
            {
                Selectable = new List <BO.Station>(bl.GetAllStationsBy(st => st.Code != code && !exists.Any((t) => t.AdjStation.Code == st.Code)).ToList());
            }
            else
            {
                Selectable = new List <BO.Station>(bl.GetAllStations());
            }

            Selected        = new List <BO.Station>();
            DataContext     = this;
            adj             = new AdjacentStation();
            adj.AverageTime = TimeSpan.Zero;
        }
Exemplo n.º 6
0
 public BadAdjacentStationsException(AdjacentStation Adj) : base() => Adjstation = Adj;