示例#1
0
        public void DisplayBookingSubMenu()
        {
            bool     running      = true;
            bool     searching    = true;
            bool     reserving    = true;
            int      campgroundID = 0;
            int      siteNumber   = 0;
            DateTime startDate    = new DateTime();
            DateTime endDate      = new DateTime();

            while (running)
            {
                VerifyingReservation(ref running, ref searching, ref campgroundID, ref startDate, ref endDate);

                Console.Clear();

                decimal totalCost = FindTotalCost(Park, campgroundID, startDate, endDate);

                ReservationHandlerDAL reservationHandler = new ReservationHandlerDAL(Park, campgroundID, startDate, endDate, DatabaseConnection);

                List <Site> availableSites = new List <Site>(reservationHandler.CheckAvailabilty(startDate, endDate));

                Console.WriteLine("Results Matching Your Search Criteria");
                Console.Write("Site No.".PadRight(10));
                Console.Write("Max Occup.".PadRight(15));
                Console.Write("Accesible?".PadRight(17));
                Console.Write("Max RV Length".PadRight(17));
                Console.Write("Utilities?".PadRight(12));
                Console.WriteLine("Cost".PadRight(10));

                foreach (var availableSite in availableSites)
                {
                    Console.WriteLine($"{availableSite.SiteID.ToString().PadRight(9)} " +
                                      $"{availableSite.MaxOccupancy.ToString().PadRight(14)} " +
                                      $"{ToYesOrNo(availableSite.Accessible).ToString().PadRight(16)} " +
                                      $"{ZeroToNA(availableSite.MaxRVLength).ToString().PadRight(16)} " +
                                      $"{ToYesOrNo(availableSite.Utilities).ToString().PadRight(11)} " +
                                      $"{totalCost.ToString("C2")}");
                }

                VerifyingCampsite(ref reserving, ref siteNumber, availableSites);
                CreatingReservation(siteNumber, reservationHandler);

                MainMenuCLI mainMenu = new MainMenuCLI();
                mainMenu.DisplayCLI();
            }
        }
示例#2
0
        /// <summary>
        /// Creates the reservation.
        /// </summary>
        /// <param name="siteNumber">The number of the site to be reserved.</param>
        /// <param name="reservationHandler">The DAL that is interfacing with the national park database to make the reservation.</param>
        private static void CreatingReservation(int siteNumber, ReservationHandlerDAL reservationHandler)
        {
            Console.WriteLine("What name should the reservation be made under? ");
            string name = Console.ReadLine();

            if (string.IsNullOrWhiteSpace(name))
            {
                Console.WriteLine("Sorry, your name must consist of 1 or more letters!");
                CreatingReservation(siteNumber, reservationHandler);
            }

            int confirmationId = reservationHandler.CreateReservation(siteNumber, name);

            Console.WriteLine($"The reservation has been made and the confirmation id is {confirmationId}.");
            System.Threading.Thread.Sleep(3000);
            Console.Clear();
        }