示例#1
0
 // savel all booking data in the database tables
 public static void SaveBooking(AbstractBooking booking, bool breakfast, bool eveningMeal)
 {
     DatabaseCalls.AddBooking(booking.BookingRefNo, booking.ArrivalDate, booking.DepartureDate,
                              booking.ChaletId, breakfast, eveningMeal);
     DatabaseCalls.CreateCustomer(booking.Client.CustomerNumber, booking.Client.Name,
                                  booking.Client.Address);
     DatabaseCalls.LinkClientToBooking(booking.BookingRefNo, booking.Client.CustomerNumber);
     foreach (var guest in booking.GuestList) // each guest is saved separately in the database
     {
         GuestDecorator guestDec = (GuestDecorator)guest;
         DatabaseCalls.CreateGuest(guestDec.Name, guestDec.PassportNumber,
                                   guestDec.Age);
         DatabaseCalls.LinkGuestToBooking(booking.BookingRefNo, guestDec.PassportNumber);
         if (guestDec.Component != null)
         {
             DatabaseCalls.LinkCustomerGuest(booking.Client.CustomerNumber, guestDec.PassportNumber);
         }
     }
     if (booking.GetType() == typeof(CarHireDecorator))
     {
         DatabaseCalls.AddCarHire(((CarHireDecorator)booking).Driver, booking.BookingRefNo,
                                  ((CarHireDecorator)booking).StartDate, ((CarHireDecorator)booking).EndDate);
     }
 }