Пример #1
0
 public void AddStation(BusStation station)
 {
     if (DataSource.ListStations.FirstOrDefault(s => s.BusStationKey == station.BusStationKey) != null)
     {
         throw new DuplicateStationException(station.BusStationKey, $"Duplicate station : {station.BusStationKey}");
     }
     DataSource.ListStations.Add(station.Clone());
 }
Пример #2
0
 void IDAL.AddStation(BusStation station)
 {
     if (DataSource.BusStations.Exists(station1 => station1.StationNumber == station.StationNumber && station1.IsAvailable3))
     {
         throw new ExceptionStation(station.StationNumber, "bad id - The Station alrady exist in the compny: {station.StationNumber}");
     }
     else
     {
         DataSource.BusStations.Add(station.Clone());
     }
 }
Пример #3
0
        public BusStation GetStation(int id)
        {
            BusStation station = DataSource.ListStations.Find(s => s.BusStationKey == id);

            if (station != null)
            {
                return(station.Clone());
            }
            else
            {
                throw new InexistantStationException(id, $"Station : {id} doesn't exist");
            }
        }
Пример #4
0
        public BusStation GetStation(int id)
        {
            BusStation station = DataSource.ListStations.Find(s => s.BusStationKey == id);

            if (station != null)
            {
                return(station.Clone());
            }
            else
            {
                throw new ArgumentException("Bus Station doesn't exist");
            }
        }
Пример #5
0
        public void UpdateStation(BusStation station)
        {
            BusStation sta = DataSource.ListStations.Find(s => s.BusStationKey == station.BusStationKey);

            if (sta != null)
            {
                DataSource.ListStations.Remove(sta);
                DataSource.ListStations.Add(station.Clone());
            }
            else
            {
                throw new InexistantStationException(station.BusStationKey, $"Station : {station.BusStationKey} doesn't exist");
            }
        }
Пример #6
0
        public void UpdateStation(BusStation station)
        {
            BusStation sta = DataSource.ListStations.Find(s => s.BusStationKey == station.BusStationKey);

            if (sta != null)
            {
                DataSource.ListStations.Remove(sta);
                DataSource.ListStations.Add(station.Clone());
            }
            else
            {
                throw new ArgumentException("station to update doesn't exist");
            }
        }
Пример #7
0
        BusStation IDAL.ReturnStation(int numberStation)
        {
            BusStation station = DataSource.BusStations.Find(station1 => station1.StationNumber == numberStation);

            return(station.Clone() ?? throw new ExceptionStation(numberStation, "bad id - The Station not exist in the compny: {numberStation}"));
        }
Пример #8
0
        void IDAL.UpdatingStation(BusStation station)
        {
            int index = DataSource.BusStations.FindIndex(station1 => station1.StationNumber == station.StationNumber);

            DataSource.BusStations[index] = index == -1 ? throw new ExceptionStation(station.StationNumber, "bad id - The Station not exist in the compny: {station.StationNumber}") : station.Clone();
        }
Пример #9
0
        void IDAL.UpdatingStation(BusStation station)
        {
            int index = DataSource.BusStations.FindIndex(station1 => station1.StationNumber == station.StationNumber);

            DataSource.BusStations[index] = index == -1 ? throw new ExceptionDl("The buses not exist in the compny") : station.Clone();
        }