Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            {
                //user input
                Console.WriteLine("Please enter your postcode to see the next buses at the two nearest bus stops:");
                string userInput = Console.ReadLine();
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                {
                    List <StopPoint> stopPointList = APIClass.GetAPIData(userInput);

                    //Prints it all nicely
                    foreach (StopPoint busStop in stopPointList.Take(2))
                    {
                        var sortedArrivals = APIClass.GetArrivalsData(busStop.naptanId);

                        Console.WriteLine($"The next buses at {busStop.commonName} are:");

                        foreach (var bus in sortedArrivals)
                        {
                            Console.WriteLine($"{bus.vehicleId} at {bus.expectedArrival}");
                        }
                    }
                    Console.ReadLine();
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult BusInfo(PostcodeSelection selection)
        {
            var info = new BusInfo(selection.Postcode);
            List <StopPoint> stopPointList = APIClass.GetAPIData(selection.Postcode);

            var BusStop1 = stopPointList[0];
            var BusStop2 = stopPointList[1];

            var sortedArrivals1 = APIClass.GetArrivalsData(BusStop1.naptanId);
            var sortedArrivals2 = APIClass.GetArrivalsData(BusStop2.naptanId);

            info.BusStop1  = BusStop1;
            info.BusStop2  = BusStop2;
            info.Arrivals1 = sortedArrivals1;
            info.Arrivals2 = sortedArrivals2;

            return(View(info));
        }