コード例 #1
0
        // retreives the customer information from a database which and reconstructs a customer object from it
        public static List <Person> GetCustomer(int customerNumber)
        {
            List <Person>       customerList     = new List <Person>();
            List <CustomerItem> customerItemList = DatabaseCalls.GetCustomersDetails(customerNumber);

            if (customerItemList.Count == 0)
            {
                return(customerList);
            }
            foreach (var item in customerItemList)
            {
                Client customer = new Client(item.Id, item.Name, item.Address);
                customerList.Add(customer);
            }

            return(customerList);
        }
コード例 #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);
        }
コード例 #3
0
 // retreives details of all customers
 public static List <CustomerItem> GelAllCustomersInfo()
 {
     return(DatabaseCalls.GetCustomersDetails(0));
 }