示例#1
0
        private void SelectPlace(SelectedPlace placeInfo)
        {
            PrintBanner();
            Console.WriteLine("You have selected " + placeInfo.result.name + ".");
            Console.WriteLine("Would you like to add a personal message to the notification?\n\n[Y] Yes\n[N] No");
            string         customMessage = "";
            ConsoleKeyInfo userChoice    = Console.ReadKey();

            while (true)
            {
                if (userChoice.KeyChar == 'y' || userChoice.KeyChar == 'Y')
                {
                    PrintBanner();
                    Console.WriteLine("Venue: " + placeInfo.result.name + "\nLocal Address: " + placeInfo.result.vicinity);
                    Console.WriteLine("\nPlease enter the message you would like to send along with the notification.\n");
                    customMessage = Console.ReadLine();
                    break;
                }
                else if (userChoice.KeyChar == 'n' || userChoice.KeyChar == 'N')
                {
                    break;
                }
            }

            Console.Clear();
            PrintBanner();
            Console.WriteLine("Please enter the numbers you would like to send the message to in the following format: (###) ###-####");
            Console.WriteLine("If you would like to send this to multiple numbers, please separate the phone numbers by semi-colons.");
            Console.WriteLine("[Enter] To Continue (Press Twice)\n[Q] To Quit To Main Menu");
            List <string> validUserNumbers = new List <string>();

            while (true)
            {
                string numbersInput = Console.ReadLine();
                userChoice = Console.ReadKey();
                if (userChoice.KeyChar == (char)ConsoleKey.Enter)
                {
                    List <string> userNumbers = numbersInput.Split(";").ToList <string>();
                    for (int i = 0; i < userNumbers.Count; ++i)
                    {
                        userNumbers[i] = userNumbers[i].Replace("(", "").Replace(")", "").Replace("-", "").Replace(" ", "").Trim();
                        if (userNumbers[i].Length == 10)
                        {
                            if (IsDigitsOnly(userNumbers[i]) == true)
                            {
                                validUserNumbers.Add("+1" + userNumbers[i]);
                            }
                        }
                    }
                    break;
                }
                else if (userChoice.KeyChar == 'n' || userChoice.KeyChar == 'N')
                {
                    break;
                }
            }
            validUserNumbers = validUserNumbers.Distinct().ToList <string>();
            PrintBanner();
            if (validUserNumbers.Count > 0)
            {
                Console.WriteLine("Sending SMS Notifications now...\n");
                int count = 0;
                foreach (string number in validUserNumbers)
                {
                    count++;
                    Console.Write("Sending #" + count.ToString());
                    Thread.Sleep(50);
                    Console.Write(".");
                    Thread.Sleep(50);
                    Console.Write(".");
                    Thread.Sleep(50);
                    Console.Write(".");
                    Thread.Sleep(50);
                    Console.Write(".");
                    Thread.Sleep(50);
                    Console.Write(".");
                    string messageBody = "\nUser Message: " + customMessage + "\n\nThe seleceted venue is: " + placeInfo.result.name + " located at " + placeInfo.result.address_components[0].long_name + " " + placeInfo.result.address_components[1].long_name + ", " + placeInfo.result.address_components[3].long_name + ", " + placeInfo.result.address_components[4].short_name + " " + placeInfo.result.address_components[6].long_name;
                    var    message     = MessageResource.Create(
                        body: messageBody,
                        from: new Twilio.Types.PhoneNumber("+15204629326"), //Shouldn't be accessible unless user has access to Protected API Token
                        to: new Twilio.Types.PhoneNumber(number)
                        );
                    ClearCurrentConsoleLine();
                    Console.WriteLine("SENT.");
                }
                PrintBanner();
                if (count > 1)
                {
                    Console.WriteLine(count.ToString() + " messages sent.");
                }
                else
                {
                    Console.WriteLine("Message sent.");
                }
                Console.WriteLine("Closing Application");
                Console.Write(".");
                Thread.Sleep(100);
                Console.Write(".");
                Thread.Sleep(100);
                Console.Write(".");
                Thread.Sleep(100);
                Console.Write(".");
                Thread.Sleep(100);
                Console.Write(".");
                Thread.Sleep(100);
                Environment.Exit(0);
            }
            else
            {
                PrintBanner();
                Console.WriteLine("There were no applicable numbers provided. We're sorry we cannot send your notification at this time.");
                AppLoading();
                PrintBanner();
                Console.WriteLine("Closing Application");
                Console.Write(".");
                Thread.Sleep(100);
                Console.Write(".");
                Thread.Sleep(100);
                Console.Write(".");
                Thread.Sleep(100);
                Console.Write(".");
                Thread.Sleep(100);
                Console.Write(".");
                Thread.Sleep(100);
                Environment.Exit(0);
            }
        }
示例#2
0
        private void ChoosePlace(List <PlacesData.Result> results)
        {
            Console.WriteLine("\n\nSearch Successful...");
            Console.WriteLine("\n[N] Select Specific Venue\n[R] Conduct Another Search\n[Q] Quit");
            ConsoleKeyInfo userChoice = Console.ReadKey();

            if (userChoice.KeyChar == 'n' || userChoice.KeyChar == 'N')
            {
                ClearCurrentConsoleLine();
                Console.WriteLine("\nPlease enter the name of the place you'd like more information on.\n");
                string place = Console.ReadLine();
                if (results.Exists(a => a.name == place))
                {
                    PrintBanner();
                    SelectedPlace placeInfo    = new SelectedPlace();
                    int           index        = results.FindIndex(a => a.name == place);
                    string        specificJson = placeInfo.InitPlaceInfo(results, index);
                    placeInfo = JsonConvert.DeserializeObject <SelectedPlace>(specificJson);
                    string[] printData = placeInfo.Info();
                    Console.WriteLine(printData[0]);
                    bool userReady = false;
                    while (userReady == false)
                    {
                        Console.WriteLine("\n[Space Bar] Display The Most Recent Reviews\n[Enter] Select This Restaurant and Notify via SMS\n[B] Return to Main Menu");
                        userChoice = Console.ReadKey();
                        if (userChoice.KeyChar == 'b' || userChoice.KeyChar == 'B')
                        {
                            PrintBanner();
                            break;
                        }
                        else if (userChoice.KeyChar == ' ')
                        {
                            Console.WriteLine("\n\n" + printData[1] + "\n\n[Space Bar] Return to Main Menu.\n[Enter] Select This Restaurant and Notify via SMS.");
                            userChoice = Console.ReadKey();
                            if (userChoice.KeyChar == (char)ConsoleKey.Enter)
                            {
                                SelectPlace(placeInfo);
                            }
                            else if (userChoice.KeyChar == ' ')
                            {
                                PrintBanner();
                                break;
                            }
                            Console.ReadKey();
                            PrintBanner();
                            break;
                        }
                        else if (userChoice.KeyChar == (char)ConsoleKey.Enter)
                        {
                            SelectPlace(placeInfo);
                        }
                    }
                }
            }
            else if (userChoice.KeyChar == 'r' || userChoice.KeyChar == 'R')
            {
            }
            else if (userChoice.KeyChar == 'q' || userChoice.KeyChar == 'Q')
            {
                PrintBanner();
                Environment.Exit(0);
            }
        }