//takes in the customer info and books the reservation in the database
        public void MakeReservation(IList <Campsite> sites, DateTime start, DateTime end)
        {
            Reservation newRes       = new Reservation();
            int         confirmation = 0;
            bool        done         = false;

            int choice = 0;

            while (!done)
            {
                choice = CLIHelper.GetInteger("\nPlease Enter the List number of the site you would like to reserve (Enter 0 to Cancel): ");

                if (choice > sites.Count)
                {
                    Console.WriteLine("Invalid choice, please try again");
                }

                else if (choice == 0)
                {
                    done = true;
                }
                else
                {
                    newRes.Site_Id     = sites[choice - 1].Site_Id;
                    newRes.Name        = CLIHelper.GetString("\nPlease enter the name to enter the reservation under: ");
                    newRes.From_Date   = start;
                    newRes.To_Date     = end;
                    newRes.Create_Date = DateTime.Now;

                    confirmation = reservationSqlDAO.BookReservation(newRes);
                    Console.WriteLine("\n\nYour reservation has been completed, your confirmation # is CGR" + confirmation);
                    Console.WriteLine("\nPlease make sure to save this for your records.  Press enter to return to the previous Menu.");

                    string answer = CLIHelper.GetYesOrNo("Would you like to get directions to your gampground? (Y)es or (N)o : ");
                    if (answer.ToLower().StartsWith("y"))
                    {
                        DirectionsDisplay.OpenBrowser(sites[choice - 1].Campground_Id - 1);
                    }
                    done = true;
                }
            }
        }
Beispiel #2
0
        private void DisplayAllSites(Campground campground)
        {
            IList <Site> sites = siteDAO.GetSiteInfo(campground.CampId, searchDateArrival, searchDateDeparture);

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("Results matching your search criteria:");

                string isAccessible       = "";
                string availableUtilities = "";
                string rvLength           = "";
                int    index = 0;

                if (sites.Count > 0)
                {
                    Console.WriteLine("Site No.".PadLeft(15).PadRight(20) + "Max Occup.".PadRight(15) + "Accessible?".PadRight(15) + "Max RV Length".PadRight(20) + "Utility".PadRight(15) + "Cost");;
                    for (int i = 0; i < sites.Count; i++)
                    {
                        index = i;
                        if (sites[i].Accessible == true)
                        {
                            isAccessible = "Yes";
                        }
                        else
                        {
                            isAccessible = "No";
                        }
                        if (sites[i].Utilities == true)
                        {
                            availableUtilities = "Yes";
                        }
                        else
                        {
                            availableUtilities = "N/A";
                        }
                        if (sites[i].MaxLengthRv == 0)
                        {
                            rvLength = "N/A";
                        }
                        else
                        {
                            rvLength = sites[i].MaxLengthRv.ToString();
                        }
                        Console.WriteLine((index + 1) + ".)".PadRight(10) + sites[i].SiteNum.ToString().PadRight(15) + sites[i].MaxOccupancy.ToString().PadRight(15) + isAccessible.PadRight(15) + rvLength.PadRight(20) + availableUtilities.PadRight(15) + campground.DailyFee.ToString("C2"));
                    }



                    DisplaySiteMenu();
                    Console.WriteLine($"** Thank you for using the National Park Reservation System. Your reservation id number is {reservationDAO.BookReservation(MakeReservation(sites[Convert.ToInt32(siteInput) -1 ]))} **");
                    Environment.Exit(0);
                }
                else
                {
                    Console.WriteLine("No sites in registry available for the given date");
                    break;
                }
            }
        }
        /// <summary>
        /// The override of ExecuteSelection handles whatever selection was made by the user.
        /// This is where any business logic is executed.
        /// </summary>
        /// <param name="choice">"Key" of the user's menu selection</param>
        /// <returns></returns>
        protected override bool ExecuteSelection(string choice)
        {
            switch (choice)
            {
            case "1":     // Do whatever option 1 is
                Console.WriteLine();
                int campgroundID = GetInteger("Which campground?");

                Console.Write("What is the arrival date? __/__/____ ");
                DateTime fromDate = Convert.ToDateTime(Console.ReadLine());

                Console.Write("What is the departure date? __/__/____ ");
                DateTime toDate = Convert.ToDateTime(Console.ReadLine());

                sites = siteDAO.SearchSitesByDate(campgroundID, fromDate, toDate);
                if (sites.Count > 0)
                {
                    SetColor(ConsoleColor.Blue);
                    Console.WriteLine(Site.PrintHeader());
                    foreach (Site site in sites)
                    {
                        Console.WriteLine(site);
                    }
                    Console.WriteLine();

                    ResetColor();

                    Console.WriteLine();
                    int site_id = GetInteger("Which site should be reserved? (enter 0 to cancel)");
                    if (site_id == 0)
                    {
                        return(true);
                    }
                    //int durationOfStay = (toDate - fromDate).Days;
                    decimal totalCost = reservationDAO.GetTotalCost(campgroundID, fromDate, toDate);
                    Console.Write($"Total cost of your stay would be {totalCost:C}. Would you like to continue? Y/N ");
                    string response = Console.ReadLine().ToUpper();
                    if (response == "N")
                    {
                        return(true);
                    }
                    string name = GetString("What name should the reservation be made under?");

                    int confirmationNumber = reservationDAO.BookReservation(site_id, name, fromDate, toDate);
                    Console.WriteLine();
                    SetColor(ConsoleColor.DarkGreen);
                    Console.WriteLine($"The reservation has been made and the confirmation id is {confirmationNumber}\nTotal Cost: {totalCost:C}");
                    ResetColor();
                    Pause("");

                    return(true);
                }
                else
                {
                    WriteError("Sorry, those dates are not available! Please try again");
                    Pause("");
                    return(true);
                }
                //case "2": // Do whatever option 2 is
                //WriteError("When this option is complete, we will exit this submenu by returning false from the ExecuteSelection method.");
                //Pause("");
                //return false;
            }
            return(true);
        }