예제 #1
0
        /// <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":     // Go to new SubMenu for Park Campgrounds
                //WriteError("Not yet implemented");
                CampgroundsMenu cm = new CampgroundsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
                cm.Run();
                Pause("");
                return(true);

            case "2":     // Go to SubMenu for Reservations
                ReservationsMenu rm = new ReservationsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
                rm.Run();
                Pause("");
                return(true);

            case "3":
                MainMenu mm = new MainMenu(campgroundDAO, parkDAO, reservationDAO, siteDAO);
                mm.Run();
                Pause("");
                return(true);
            }
            return(true);
        }
예제 #2
0
        //Execute selection from options menu
        protected override bool ExecuteSelection(string choice)
        {
            campgroundList = campgroundDAO.GetCampgrounds(myPark.Park_Id);

            switch (choice)
            {
            case "1":
                CampgroundsMenu campgroundsMenu = new CampgroundsMenu(parkdao, campgroundDAO, reservationDAO, siteDAO, myPark);
                campgroundsMenu.Run();
                return(true);

            case "2":
                CampSiteMenu menu = new CampSiteMenu(parkdao, campgroundDAO, reservationDAO, siteDAO, campgroundList);
                menu.Run();

                return(true);
            }
            return(true);
        }
        /// <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": // Go to new SubMenu for Reservations
        //            //WriteError("Not yet implemented");
        //            //ReservationsMenu rm = new ReservationsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
        //            //rm.Run();
        //            //Pause("");
        //            return true;
        //    }
        //    return true;
        //}
        #region Original SearchForAvailableReservations - No longer using
        //private void SearchForAvailableReservations()
        //{
        //    IList<Campground> campgrounds = campgroundDAO.GetCampgroundsByParkId(selectedPark.ParkId);
        //    string pickCampground = CLIMenu.GetString("Which campground would you like (enter 0 to cancel)?");
        //    if (pickCampground == "0")
        //    {
        //        CampgroundsMenu cm = new CampgroundsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
        //        cm.Run();
        //        Pause("");
        //    }
        //    else if ((Convert.ToInt32(pickCampground)) > campgrounds.Count)
        //    {
        //        Console.WriteLine("Please choose a valid campground");
        //        Pause("");
        //        ReservationsMenu rm = new ReservationsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
        //        rm.Run();
        //        Pause("");
        //    }

        //    //pulled out of else statement as not needed removed as not needed
        //    string arrivalDate = CLIMenu.GetDateTime("What is the arrival date?");
        //    DateTime.TryParse(arrivalDate, out DateTime arrival); // Adding in a parse for arrival date to make sure that the arrival date is before the departure date
        //    string departureDate = CLIMenu.GetDateTime("What is the departure date?");
        //    DateTime.TryParse(departureDate, out DateTime departure);// Adding in a parse for departure date to make sure that the arrival date is before the departure date
        //    if (arrival > departure)
        //    {
        //        Console.WriteLine("Your departure date cannot be before your arrival date. Please try again with a valid date of departure.");
        //        Pause("");
        //        ReservationsMenu rm = new ReservationsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
        //        rm.Run();
        //        Pause("");
        //    }

        //    IList<Site> sites = siteDAO.ViewAvailableReservations(pickCampground, arrivalDate, departureDate);
        //    if (sites.Count > 0)
        //    {
        //        decimal campgroundCost = campgroundDAO.GetCampgroundCost(pickCampground);
        //        Console.WriteLine("Results Matching Your Search Criteria");
        //        Console.WriteLine($"{"Site No.",-10} {"Max Occupancy",10} {"Accessible?",14} {"Max RV Length",18} {"Utility",11} {"Cost",6}");

        //        foreach (Site site in sites)
        //        {
        //            Console.WriteLine($"{site.SiteId,-10} {site.MaxOccupancy,-16} {site.Accessible.ToYesNo(),-16} {site.MaxRVLength.ToLengthNA(),-17} {site.Utilities.ToYesNA(),-9} {campgroundCost.ToString("C"),0}");

        //        }
        //        Console.WriteLine();
        //        string siteToReserve = CLIMenu.GetString("Which site should be reserved (enter 0 to cancel)");
        //        if (siteToReserve == "0")
        //        {
        //            ReservationsMenu rm = new ReservationsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
        //            rm.Run();
        //            Pause("");
        //        }
        //        //else if ((Convert.ToInt32(siteToReserve)) > sites.Count)
        //        //{
        //        //    Console.WriteLine("Please choose a valid site");
        //        //    Pause("");
        //        //}
        //        bool siteExistsInList = false;

        //        foreach (Site site in sites)
        //        {
        //            if (site.SiteId.ToString() == siteToReserve)
        //            {
        //                siteExistsInList = true;
        //            }
        //        }

        //        if (!siteExistsInList)
        //        {
        //            Console.WriteLine("We're sorry, that Site ID is not in our list. Please try again.");
        //            return;
        //        }

        //        string name = CLIMenu.GetString("What name should the reservation be made under?");
        //        MakeReservation(siteToReserve, name, arrivalDate, departureDate);
        //    }
        //    else
        //    {
        //        Console.WriteLine("We're sorry, there are no campsites available. Please try again with different dates.");
        //        return;
        //    }


        //}
        #endregion

        private void SearchForAvailableReservations()
        {
            IList <Campground> campgrounds    = campgroundDAO.GetCampgroundsByParkId(selectedPark.ParkId);
            string             pickCampground = CLIMenu.GetString("Which campground would you like (enter 0 to cancel)?");

            if (pickCampground == "0")
            {
                CampgroundsMenu cm = new CampgroundsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
                cm.Run();
                Pause("");
            }
            else if ((Convert.ToInt32(pickCampground)) > campgrounds.Count)
            {
                Console.WriteLine("Please choose a valid campground");
                Pause("");
                ReservationsMenu rm = new ReservationsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
                rm.Run();
                Pause("");
            }

            while (true)
            {
                // Putting into a while statement to re-prompt user for input when inputting invalid information
                string arrivalDate   = CLIMenu.GetDateTime("What is the arrival date? (DD/MM/YYYY)");
                string departureDate = CLIMenu.GetDateTime("What is the departure date? (DD/MM/YYYY)");
                while (true)
                {
                    DateTime.TryParse(arrivalDate, out DateTime arrival);     // Adding in a parse for arrival date to make sure that the arrival date is before the departure date
                    DateTime.TryParse(departureDate, out DateTime departure); // Adding in a parse for departure date to make sure that the arrival date is before the departure date
                    if (arrival > departure)                                  // check to make sure that the arrival date is before the departure date
                    {
                        Console.WriteLine("Your departure date cannot be before your arrival date. Please try again with a valid date of departure.");
                        break;
                    }


                    IList <Site> sites = siteDAO.ViewAvailableReservations(pickCampground, arrivalDate, departureDate);
                    if (sites.Count > 0)
                    {
                        decimal campgroundCost = campgroundDAO.GetCampgroundCost(pickCampground);
                        Console.WriteLine("Results Matching Your Search Criteria");
                        Console.WriteLine($"{"Site No.",-10} {"Max Occupancy",10} {"Accessible?",14} {"Max RV Length",18} {"Utility",11} {"Cost",6}");

                        foreach (Site site in sites)
                        {
                            Console.WriteLine($"{site.SiteNumber,-10} {site.MaxOccupancy,-16} {site.Accessible.ToYesNo(),-16} {site.MaxRVLength.ToLengthNA(),-17} {site.Utilities.ToYesNA(),-9} {campgroundCost.ToString("C"),0}");
                        }
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("We're sorry, there are no campsites available. Please try again with different dates.");
                        break;
                    }
                    string siteToReserve = CLIMenu.GetString("Which site should be reserved (enter 0 to cancel)");
                    while (true)
                    {
                        #region Site to reserve area
                        if (siteToReserve == "0")
                        {
                            ReservationsMenu rm = new ReservationsMenu(selectedPark, campgroundDAO, parkDAO, reservationDAO, siteDAO);
                            rm.Run();
                            Pause("");
                        }
                        else if (siteToReserve != "0")
                        {
                            foreach (Site site in sites)
                            {
                                if (site.SiteNumber == Convert.ToInt32(siteToReserve))
                                {
                                    string name = CLIMenu.GetString("What name should the reservation be made under?");
                                    MakeReservation(siteToReserve, name, arrivalDate, departureDate);
                                    break;
                                }
                            }
                            Console.WriteLine("We're sorry, that Site number is not in our list. Please try again.");
                            Pause("");
                            Console.Clear(); // Clear the menu as to not clutter the experience for the user
                            // Add in the BeforeDisplayMenu, Arrival Date & Departure Date from user with the original message
                            BeforeDisplayMenu();
                            Console.WriteLine($"What is the arrival date? (DD/MM/YYYY) {arrivalDate}");
                            Console.WriteLine($"What is the departure date? (DD/MM/YYYY) {departureDate}");
                            break;
                        }

                        #endregion
                    }
                }
            }
        }