// public string CheckIn(string username, string tripId, IEnumerable <int> bagIndices) { IPassenger passenger = this.airport.GetPassenger(username); ITrip trip = airport.GetTrip(tripId); bool checkedIn = trip.Airplane.Passengers.Any(p => p.Username == username); if (checkedIn) { throw new InvalidOperationException($"{passenger.Username} is already checked in!"); } int confiscatedBags = CheckInBags(passenger, bagIndices); trip.Airplane.AddPassenger(passenger); return($"Checked in {passenger.Username} with {bagIndices.Count() - confiscatedBags}/{bagIndices.Count()} checked in bags"); }
public string CheckIn(string username, string tripId, IEnumerable <int> bagIndexes) { IPassenger passenger = this.airport.GetPassenger(username); ITrip trip = airport.GetTrip(tripId); bool IsCheckedIn = airport.Trips.SelectMany(x => x.Airplane.Passengers).Contains(passenger); if (IsCheckedIn) { throw new InvalidOperationException($"{username} is already checked in!"); } var confiscatedBags = CheckInBags(passenger, bagIndexes); trip.Airplane.AddPassenger(passenger); return ($"Checked in {passenger.Username} with {bagIndexes.Count() - confiscatedBags}/{bagIndexes.Count()} checked in bags"); }