/* * 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); }
/* * 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); }
/* * Returns the current booking's departure and arrival dates. */ public void GetCurrentBookDates(out DateTime arrival, out DateTime departure) { CurrentBook.GetDates(out arrival, out departure); }