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