コード例 #1
0
ファイル: Program.cs プロジェクト: SChandarana/BusBoard
        static void Main(string[] args)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            var tflApiHelper      = new TflApiHelper();
            var postcodeApiHelper = new PostcodeApiHelper();

            while (true)
            {
                Console.WriteLine("Welcome to the BusBoard please enter a postcode you wish to check or 'exit' to exit");
                var input = Console.ReadLine();
                if (input == "exit")
                {
                    Console.WriteLine("Thank you for using BusBoard");
                    break;
                }

                var coordinate = postcodeApiHelper.GetPostcodeCoordinates(input);
                var stopPoints = tflApiHelper.GetStopPoints(coordinate);
                var output     = stopPoints
                                 .Take(2)
                                 .SelectMany(stop => tflApiHelper.GetTopFiveBuses(stop.naptanId));
                Console.WriteLine(
                    string.Join("\n", output.Select(bus => bus.GetBusData())));
            }
        }
コード例 #2
0
        public ActionResult BusInfo(PostcodeSelection selection)
        {
            var coordinate = postcodeApiHelper.GetPostcodeCoordinates(selection.Postcode);
            var stopPoints = tflApiHelper.GetStopPoints(coordinate);
            var stops      = stopPoints
                             .Take(2)
                             .Select(stop => tflApiHelper.GetTopFiveBuses(stop.naptanId));
            var info = new BusInfo(stops);

            return(View(info));
        }