/* * Updates the BookingComponent instance currently loaded in the * system. */ public void UpdateBooking(DateTime arrival, DateTime departure) { List <PersonComponent> savedGuests = CurrentBook.GetGuests(); List <BookingDecorator> decorationStack; BookingComponent booking = CurrentBook.Unwrap(out decorationStack); booking = bFact.UpdateBooking(booking.GetBookingNb(), CurrentCust, arrival, departure); if (decorationStack != null) { foreach (BookingDecorator reference in decorationStack) { reference.Setcomponent(booking); booking = reference; } } CurrentBook = booking; foreach (PersonComponent g in savedGuests) { CurrentBook.AddGuest(g); } }
/* * Deletes the guest at given index in list of guests for the * current booking. * Undecorates that guest if if it is also a * customer and updates CurrentCustomer with the correct * memory reference. */ public void DeleteGuest(int index) { // First unwrap guest decorator from current customer if they are // the guest being deleted: if (CurrentBook.GetGuests().ElementAt(index).IsCustomer()) { List <PersonComponent> savedGuests = CurrentBook.GetGuests(); DateTime arrival; DateTime departure; CurrentBook.GetDates(out arrival, out departure); CurrentCust = CurrentCust.UndecorateOnce(); CurrentBook = bFact.UpdateBooking(CurrentBook.GetBookingNb(), CurrentCust, arrival, departure); foreach (PersonComponent g in savedGuests) { CurrentBook.GetGuests().Add(g); } } // Then delete selected guest reference from guests list: CurrentBook.GetGuests().RemoveAt(index); }
/* * Returns a list of the names of all the guests currently booked for * the current booking. */ public List <String> GetGuestNames() { List <String> guestNames = new List <String>(); foreach (PersonComponent g in CurrentBook.GetGuests()) { guestNames.Add(g.Name); } return(guestNames); }
/* * Updates guest details of current customer at given index in current * booking's list of guests. */ public void EditCustomerGuestDetails(int index, String passportNb, int age) { CurrentBook.GetGuests().RemoveAt(index); CurrentBook.GetGuests().Insert(index, pFact.GetNewGuest( CurrentCust.UndecorateOnce(), passportNb, age)); }
/* * True if the element at given index in list of guests is a * cutomer. */ public bool IsGuestACustomer(int index) { if (index >= 0) { return(CurrentBook.GetGuests().ElementAt(index).IsCustomer()); } else { return(false); } }
/* * Updates details of guest at given index in current booking's * list of guests. */ public void EditGuest(int index, String name, String passportNb, int age) { CurrentBook.GetGuests().RemoveAt(index); CurrentBook.GetGuests().Insert(index, pFact.GetNewGuest(name, passportNb, age)); }
/* * Adds current customer to current booking's list of guests. */ public void AddCustomerToGuests(String passportNb, int age) { List <PersonComponent> savedGuests = CurrentBook.GetGuests(); DateTime arrival; DateTime departure; CurrentBook.GetDates(out arrival, out departure); CurrentCust = pFact.GetNewGuest(CurrentCust, passportNb, age); CurrentBook = bFact.UpdateBooking(CurrentBook.GetBookingNb(), CurrentCust, arrival, departure); foreach (PersonComponent g in savedGuests) { CurrentBook.GetGuests().Add(g); } CurrentBook.AddGuest(CurrentCust); }