public void AddGuest(string bookingReferenceNumber, string name, string passport, string age) { int bookingRef = ReservationSystem.RefToInt(bookingReferenceNumber); int guestAge = ReservationSystem.RefToInt(age); bool guestExists = false; Guest newGuest = new Guest(name, passport, guestAge, bookingRef); foreach (Guest guest in guests) { if (guest.PassportNo == passport && guest.BookingReferenceNumber == bookingRef) //One guest can be assigned to multiple bookings { guestExists = true; break; } } if (guestExists == false) { guests.Add(newGuest); } else { throw new ArgumentException("Guest exists"); } }
public Booking GetSingleBooking(string bookingReference) { int refNo = ReservationSystem.RefToInt(bookingReference); foreach (Booking booking in bookings) { if (booking.ReferenceNumber == refNo) { return(booking); } } return(null); }
public List <Guest> ListGuests(string bookingReferenceNumber) { int referenceNumber = ReservationSystem.RefToInt(bookingReferenceNumber); List <Guest> temp = new List <Guest>(); foreach (Guest guest in guests) { if (guest.BookingReferenceNumber == referenceNumber) { temp.Add(guest); } } return(temp); }
public void DeleteBooking(string bookingReference) { int refNo = ReservationSystem.RefToInt(bookingReference); bookings.RemoveAll(x => x.ReferenceNumber == refNo); }