Beispiel #1
0
        // logic for add new guest button. Adds a new guest to the current booking object and to the database
        private void btnNewGuestConf_Click(object sender, RoutedEventArgs e)
        {
            BusinessFacadeSingleton businessFacase = BusinessFacadeSingleton.Instance();
            var newguest = businessFacase.CreateGuest(txtBoxEditName.Text, txtBoxEditPassp.Text,
                                                      Convert.ToInt32(txtBoxEditAge.Text));

            booking.GuestList.Add(newguest);
            listBoxGuests.Items.Add(newguest.Name);
            DataLayerFacade.AddGuestToBooking(bookingRef, txtBoxEditName.Text,
                                              txtBoxEditPassp.Text, Convert.ToInt32(txtBoxEditAge.Text));
            txtBoxEditAge.Text   = "";
            txtBoxEditName.Text  = "";
            txtBoxEditPassp.Text = "";
            HideAddNewGuestControls();
        }
Beispiel #2
0
        // retreives all information for a booking and reconstructs it into an object
        public static AbstractBooking RetreiveBooking(int bookingId)
        {
            Client                  customer       = null;
            List <Person>           guestList      = new List <Person>();
            int                     customerRef    = DatabaseCalls.GetCustIdForBooking(bookingId);
            CustomerItem            customerItem   = DatabaseCalls.GetCustomersDetails(customerRef).ElementAt(0);
            BusinessFacadeSingleton businessFacade = BusinessFacadeSingleton.Instance();

            customer = businessFacade.CreateClient(customerItem.Id, customerItem.Name, customerItem.Address);

            foreach (var guestItem in DatabaseCalls.GetGuestsDetails(0, bookingId))
            {
                GuestDecorator guest = businessFacade.CreateGuest(guestItem.Name, guestItem.PassportNumber, guestItem.Age);
                if (DatabaseCalls.IsCustomer(guest.Name))
                {
                    guest.SetComponent(customer);
                }
                guestList.Add(guest);
            }
            BookingItem bookingItem = DatabaseCalls.GetBookingDetails(bookingId);
            CarHireItem carHireItem = DatabaseCalls.GetCarHireDetails(bookingId);
            bool        carHire     = false;
            string      driver      = "";
            DateTime    hireStart   = DateTime.Today;
            DateTime    hireEnd     = DateTime.Today;

            if (carHireItem != null)
            {
                carHire   = true;
                driver    = carHireItem.Driver;
                hireStart = carHireItem.HireStart;
                hireEnd   = carHireItem.HireEnd;
            }
            var booking = businessFacade.CreateBooking(bookingId, bookingItem.Arrival, bookingItem.Departure, customer, guestList,
                                                       bookingItem.ChaletId, bookingItem.EveningMeal, bookingItem.Breakfast, carHire, hireStart,
                                                       hireEnd, driver);

            return(booking);
        }