예제 #1
0
        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");
            }
        }
예제 #2
0
        public Booking GetSingleBooking(string bookingReference)
        {
            int refNo = ReservationSystem.RefToInt(bookingReference);

            foreach (Booking booking in bookings)
            {
                if (booking.ReferenceNumber == refNo)
                {
                    return(booking);
                }
            }
            return(null);
        }
예제 #3
0
        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);
        }
예제 #4
0
        public void DeleteBooking(string bookingReference)
        {
            int refNo = ReservationSystem.RefToInt(bookingReference);

            bookings.RemoveAll(x => x.ReferenceNumber == refNo);
        }