Example #1
0
        /// <summary>
        /// Displays the upcoming reservations for a park for the user.
        /// </summary>
        /// <param name="park"></param>
        private void ShowUpcomingReservationsMenu(Park park)
        {
            const ConsoleKey QUIT_KEY = ConsoleKey.Q;

            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                PrintColoredMessage($"Here are the upcoming reservations for the next 30 days at {park.Name}: ", ConsoleColor.Yellow);

                var reservations = Npsd.GetUpcomingParkReservations(park);

                Console.WriteLine();
                PrintColoredMessage("Name".PadRight(40) + "Arrival Date".PadRight(15) + "Departure Date", ConsoleColor.Yellow);

                foreach (var reservation in reservations)
                {
                    Console.WriteLine($"{reservation.Name.PadRight(40)}{reservation.ToDate.ToShortDateString().ToString().PadRight(15)}{reservation.FromDate.ToShortDateString()}");
                }

                Console.WriteLine();
                Console.WriteLine($"{QUIT_KEY}) Return to prior menu");

                var userSelection = Console.ReadKey(true).Key;

                if (userSelection == QUIT_KEY)
                {
                    exit = true;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Displays the history of reservations for the current user.
        /// </summary>
        private void ShowUserHistoryMenu()
        {
            const ConsoleKey RETURN_KEY = ConsoleKey.Q;

            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                PrintColoredMessage($"Reservation user history for {Mgr.User.Username}:", ConsoleColor.Yellow);

                var userHisory = Npsd.GetUserReservationHistory(Mgr.User.Id);

                Console.WriteLine();
                PrintColoredMessage("Reservation ID".PadRight(15) + "Name".PadRight(40) + "Arrival Date".PadRight(15) +
                                    "Departure Date".PadRight(15), ConsoleColor.Yellow);

                foreach (var reservation in userHisory)
                {
                    Console.WriteLine($"{reservation.ReservationId.ToString().PadRight(15)}" +
                                      $"{reservation.Name.PadRight(40)}{reservation.ToDate.ToShortDateString().ToString().PadRight(15)}" +
                                      $"{reservation.FromDate.ToShortDateString()}");
                }

                Console.WriteLine();
                Console.WriteLine($"{RETURN_KEY}) Return to prior menu");
                var userSelection = Console.ReadKey(true).Key;

                if (userSelection == RETURN_KEY)
                {
                    exit = true;
                }
            }
        }
Example #3
0
        /// <summary>
        /// Main menu for
        /// </summary>
        private void NationalParksMenu()
        {
            bool exit = false;

            while (!exit)
            {
                var parks = Npsd.GetParks();

                Console.Clear();

                PrintColoredMessage($"Welcome to national parks, {Mgr.User.FirstName}!", ConsoleColor.Yellow);
                Console.WriteLine();
                Console.WriteLine($"Select a Park for further details:");

                foreach (var park in parks)
                {
                    Console.WriteLine($"{park.Key}) {park.Value.Name}");
                }

                Console.WriteLine();
                Console.WriteLine("H) Show user history");
                Console.WriteLine("Q) Quit");
                string userSelection = Console.ReadLine();

                if (userSelection == "Q" || userSelection == "q" ||
                    userSelection == "Quit" || userSelection == "quit")
                {
                    exit = true;
                }
                else if (userSelection == "H" || userSelection == "h" ||
                         userSelection == "History" || userSelection == "history")
                {
                    ShowUserHistoryMenu();
                }
                else if (int.TryParse(userSelection, out int selectionNumber))
                {
                    try
                    {
                        ParkMenu(parks[selectionNumber]);
                    }
                    catch (KeyNotFoundException)
                    {
                        PrintMessageToScreen("Invalid selection, please try again...");
                    }
                }
                else
                {
                    PrintMessageToScreen("Invalid selection, please try again...");
                }
            }
        }
Example #4
0
        /// <summary>
        /// Asks the user for the inputs required for a park wide search.
        /// </summary>
        /// <param name="park"></param>
        private void ParkWideSearchAskInputsMenu(Park park)
        {
            var camps = Npsd.GetCampgrounds(park);

            Console.WriteLine();

            DateTime arrivalDate   = ParseUserDateRequired("What is the arrival date (MM/DD/YYYY)? ");
            DateTime departureDate = ParseUserDateRequired("What is the departure date (MM/DD/YYYY)? ");

            if (arrivalDate > DateTime.Now && departureDate > arrivalDate)
            {
                int  occupancy  = ParseUserInputRequired("Number of occupants? ");
                bool accessible = ParseUserBoolRequired("Accessiblity requirements (true, false): ");
                int  rvLength   = ParseUserInputRequired("RV Length requirements (0 if no RV): ");
                bool utility    = ParseUserBoolRequired("Utility hookup Required (true, false)? ");

                SearchParkWideForAvailableReservationsMenu(park, occupancy, accessible, rvLength, utility, arrivalDate, departureDate);
            }
            else
            {
                PrintMessageToScreen("Invalid date entry, please try again...");
            }
        }
Example #5
0
        /// <summary>
        /// Takes inputs from the user to display a menu for available reservations parkwide to select from.
        /// </summary>
        /// <param name="park"></param>
        /// <param name="occupancy"></param>
        /// <param name="accessible"></param>
        /// <param name="rvLength"></param>
        /// <param name="utility"></param>
        /// <param name="arrivalDate"></param>
        /// <param name="departureDate"></param>
        private void SearchParkWideForAvailableReservationsMenu(Park park, int occupancy, bool accessible, int rvLength,
                                                                bool utility, DateTime arrivalDate, DateTime departureDate)
        {
            const ConsoleKey MAKE_RESERVATION_KEY = ConsoleKey.D1;
            const ConsoleKey QUIT_KEY             = ConsoleKey.Q;

            bool exit = false;

            while (!exit)
            {
                Console.Clear();

                var sites = Npsd.GetAvailableSitesParkWide(park, occupancy, accessible, rvLength, utility, arrivalDate, departureDate);

                Console.WriteLine("Campground".PadRight(20) + "Site No.".PadRight(20) + "Max Occup.".PadRight(20) + "Accessible?".PadRight(20) + "Max RV Length".PadRight(20)
                                  + "Utility".PadRight(20) + "Cost");

                foreach (var site in sites)
                {
                    Campground camp = Npsd.GetCampgroundForSite(site.Value.SiteId);

                    Console.WriteLine($"{camp.Name.PadRight(20)}{site.Value.SiteNumber.ToString().PadRight(20)}{site.Value.MaxOccupancy.ToString().PadRight(20)}" +
                                      $"{site.Value.Accessible.ToString().PadRight(20)} {site.Value.MaxRvLength.ToString().PadRight(20)}" +
                                      $"{site.Value.Utilities.ToString().PadRight(20)}{camp.CalculateFees(arrivalDate, departureDate):c}");
                }

                if (sites.Count == 0)
                {
                    Console.WriteLine("Sorry, there aren't any available sites with your requirements.");
                }

                Console.WriteLine();
                Console.WriteLine("Available Options:");
                Console.WriteLine($"{MAKE_RESERVATION_KEY.ToString().Substring(1)}) Make Reservation.");
                Console.WriteLine($"{QUIT_KEY}) Return to prior menu.");

                ConsoleKey userSelection = Console.ReadKey(true).Key;

                Console.WriteLine();

                if (userSelection == MAKE_RESERVATION_KEY && sites.Count > 0)
                {
                    int siteSelection = ParseUserInputRequired("Which site should be reserved (enter 0 to cancel)? ");

                    if (siteSelection != 0 && sites.ContainsKey(siteSelection))
                    {
                        string reservationName = AskUserForInputRequired("What name should the reservation be made under? ");

                        try
                        {
                            int reservationId = Npsd.MakeReservation(Mgr.User.Id, sites[siteSelection].SiteId, reservationName, arrivalDate, departureDate);

                            PrintMessageToScreen($"The reservation has been made and the confirmation id is {reservationId}");
                        }
                        catch
                        {
                            PrintMessageToScreen("Failed in making a reservation, please try again.");
                        }
                    }
                    else if (siteSelection != 0 && !sites.ContainsKey(siteSelection))
                    {
                        PrintMessageToScreen("Invalid site selection, please try again...");
                    }
                }
                else if (userSelection == QUIT_KEY)
                {
                    exit = true;
                }
            }
        }
Example #6
0
        /// <summary>
        /// View all the campgrounds for that park.
        /// </summary>
        /// <param name="park"></param>
        private void ViewCampground(Park park)
        {
            const ConsoleKey SEARCH_RESERVATION_KEY = ConsoleKey.D1;
            const ConsoleKey RETURN_KEY             = ConsoleKey.D2;
            var camps = Npsd.GetCampgrounds(park);

            bool exit = false;

            while (!exit)
            {
                Console.Clear();
                Console.WriteLine("   Name".PadRight(39) + "Open".PadRight(11) + "Close".PadRight(11) + "Daily Fee");

                foreach (var camp in camps)
                {
                    Console.WriteLine($"{camp.Key}) {camp.Value.Name.PadRight(35)} {camp.Value.OpeningMonth.PadRight(10)}" +
                                      $" {camp.Value.ClosingMonth.PadRight(10)} {camp.Value.DailyFee:c}");
                }

                Console.WriteLine();
                Console.WriteLine("Select a Command");
                Console.WriteLine($"{SEARCH_RESERVATION_KEY.ToString().Substring(1)}) Search for Available Reservation");
                Console.WriteLine($"{RETURN_KEY.ToString().Substring(1)}) Return to Previous Screen");

                var userSelection = Console.ReadKey(true).Key;

                if (userSelection == SEARCH_RESERVATION_KEY)
                {
                    Console.WriteLine();

                    int campSelected = ParseUserInputRequired("Which campground (enter 0 to cancel)? ");

                    if (campSelected != 0 && camps.ContainsKey(campSelected))
                    {
                        DateTime arrivalDate   = ParseUserDateRequired("What is the arrival date (MM/DD/YYYY)? ");
                        DateTime departureDate = ParseUserDateRequired("What is the departure date (MM/DD/YYYY)? ");

                        if (arrivalDate > DateTime.Now && departureDate > arrivalDate)
                        {
                            if (camps[campSelected].CampOpenInDateRange(arrivalDate, departureDate))
                            {
                                int  occupancy  = ParseUserInputRequired("Number of occupants? ");
                                bool accessible = ParseUserBoolRequired("Accessiblity requirements (true, false): ");
                                int  rvLength   = ParseUserInputRequired("RV Length requirements (0 if no RV): ");
                                bool utility    = ParseUserBoolRequired("Utility hookup Required (true, false)? ");

                                SearchCampgroundForAvailableReservationMenu(camps[campSelected], occupancy, accessible, rvLength, utility, arrivalDate, departureDate);
                            }
                            else
                            {
                                PrintMessageToScreen("Sorry the campground is closed in that date range. Please try a different date range.");
                            }
                        }
                        else
                        {
                            PrintMessageToScreen("Invalid date entry, please try again...");
                        }
                    }
                    else if (campSelected != 0 && !camps.ContainsKey(campSelected))
                    {
                        PrintMessageToScreen("Invalid camp selection, please try again...");
                    }
                }
                else if (userSelection == RETURN_KEY)
                {
                    exit = true;
                }
            }
        }