private void OnAddPassangerEventRaise(object sender, PassengerEventArgs e) { if (_airport.FindByNumber(e.FlightNumber) != null) { _airport.AddPassenger(e.FlightNumber, e.Passenger); } else { _view.PrintError("The flight is not exsist"); } }
//If the airport already has a passenger with that username, //throw an InvalidOperationException with the message "Passenger {username} already registered!". //The command adds a new passenger into the airport and returns "Registered {passenger.Username}" public string RegisterPassenger(string userName) { IPassenger passenger = airport.GetPassenger(userName); if (passenger != null) { throw new InvalidOperationException($"Passenger {userName} already registered"); } passenger = new Passenger(userName); airport.AddPassenger(passenger); return($"Registered {passenger.Username}"); }