Пример #1
0
        private void GetVenues()
        {
            try
            {
                //requires a try catch around it because we parse inside a while loop
                bool done = false;
                while (!done)
                {
                    IList <Venue> venues = venueDAO.GetVenues();
                    Console.WriteLine("~~ View Venues Menu ~~");
                    Console.WriteLine("Please type in the number of the venue you want to select below");
                    for (int index = 0; index < venues.Count; index++) //if they hit any number other than a venue number, goes back a menu
                    {
                        Console.WriteLine(index + 1 + ") - " + venues[index].Name);
                    }
                    Console.WriteLine("Press any other key to RETURN to our main menu.");
                    string userInput = Console.ReadLine();

                    int inputNumber   = int.Parse(userInput);
                    int venueIndexNum = inputNumber - 1;

                    if ((venueIndexNum >= 0) && (venueIndexNum < venues.Count))
                    {
                        VenueDetailsMenu(venueIndexNum);
                    }


                    else
                    {
                        done = true;
                    }
                }
            }
            catch (System.FormatException)
            {
                Console.WriteLine("Please enter a valid venue number");
                return;
            }
        }
Пример #2
0
        /// <summary>
        /// This method is the second menu that displays out to the User.
        /// Will display Venue Details out to the user if they wish.
        /// </summary>
        public void RunListVenuesMenu()
        {
            Venue VenueDetails = new Venue();

            bool stayInListVenuesMenu = true;

            while (stayInListVenuesMenu)
            {
                // Print out Venues and Quit Option
                DisplayListVenuesMenu();

                IList <Venue> listOfVenues = venueDAO.GetVenues();
                // Method that gets and checks the User Input
                //int userInputVenueID = CheckVenueIDAndDisplayVenue(listOfVenues);

                VenueDetails = new Venue();
                string userInput          = "";
                int    convertedUserInput = -1; // Stores the user input string converted into an int.
                bool   validOrNot;              // Stores the bool of whether or not the User Input could be parsed to an int.

                List <int> venueIds = new List <int>();

                foreach (Venue venue in listOfVenues)
                {
                    venueIds.Add(venue.id);
                }

                do
                {
                    userInput = Console.ReadLine();

                    // If the user types in "r" or "R"
                    if (userInput.ToLower().Equals("r"))
                    {
                        validOrNot = true;
                        break;
                    }

                    validOrNot = int.TryParse(userInput, out convertedUserInput);

                    // If the TryParse fails...
                    if (validOrNot == false)
                    {
                        Console.WriteLine("1)Please enter a valid venue id.");
                    }
                    // If the TryParse doesn't fail but isn't one of the available space ids...
                    else if (!venueIds.Contains(convertedUserInput))
                    {
                        Console.WriteLine("2)Please enter a valid venue id.");
                        validOrNot = false;
                    }
                }while (!validOrNot);

                if (userInput.ToLower().Equals("r"))
                {
                    break;
                    stayInListVenuesMenu = false;
                }
                else
                {
                    // Create a new Venue with the information it needs to display to the User
                    // Needs a check to see if the selected venue is a valid option
                    VenueDetails = venueDAO.ListVenue(convertedUserInput);

                    Console.WriteLine();
                    Console.WriteLine(VenueDetails.name);
                    Console.WriteLine($"Location: {VenueDetails.location}");
                    Console.WriteLine($"Categories: {VenueDetails.categoryName}");
                    Console.WriteLine();
                    Console.WriteLine(VenueDetails.description);
                    Console.WriteLine();

                    // Move to the Venue Details Menu
                    RunVenueDetailsMenu(convertedUserInput.ToString(), VenueDetails);
                }
            }
        }