/*
  * Adds Guests to a BookingComponent according to data contents of a
  * dictonary<attribute, values>, presumably recovered from persisted
  * data (the dictonary keys should follow the naming implemented in
  * the *Field.cs enumerations)
  */
 private BookingComponent addGuestsData(
     BookingComponent b,
     List <Dictionary <String, String> > gData)
 {
     foreach (Dictionary <String, String> d in gData)
     {
         b.AddGuest(personFactory.RestoreGuest(d));
     }
     return(b);
 }
        /*
         * Instantiates a BookingComponent from a
         * List<Dictonary<attribute, values>>, presumably recovered from
         * persisted data (the dictonaries keys should follow the naming
         * implemented in the *Field.cs enumerations)
         *
         * Thows Argument exception if there is a problem with the contents
         * of the dictionary passed as a parameter.
         */
        public BookingComponent Restore(
            List <Dictionary <String, String> > booking)
        {
            BookingComponent result = null;

            Dictionary <String, String>         bData;
            Dictionary <String, String>         cData;
            List <Dictionary <String, String> > guestsData;

            extract(booking, out bData, out cData, out guestsData);

            String bookingNb;
            String csvArrival;
            String csvDeparture;

            if (bData != null &&
                cData != null &&
                bData.TryGetValue(BookingField.BOOKING_NUMBER.ToString(),
                                  out bookingNb) &&
                bData.TryGetValue(BookingField.ARRIVAL.ToString(),
                                  out csvArrival) &&
                bData.TryGetValue(BookingField.DEPARTURE.ToString(),
                                  out csvDeparture))
            {
                result = getNewBooking(Int32.Parse(bookingNb),
                                       personFactory.RestoreCustomer(cData),
                                       Convert.ToDateTime(csvArrival),
                                       Convert.ToDateTime(csvDeparture));

                if (result.GetCustomer().IsGuest())
                {
                    result.AddGuest(result.GetCustomer());
                }
            }

            result = addGuestsData(result, guestsData);
            result = addExtrasData(result, bData);
            return(result);
        }