static void Main(string[] args) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var tflApi = new TflApi(); var postcodeApi = new PostCodeApi(); Console.Write("Enter your postcode."); string postcode = Console.ReadLine(); PostcodeLocation location = postcodeApi.GetLongLat(postcode); string stopcode = tflApi.GetStopCodeNearLocation(location.longitude, location.latitude); var nextBusses = tflApi.GetNextArrivalsForStop(stopcode); List <Bus> bussesSorted = nextBusses.OrderBy(b => Convert.ToInt32(b.TimeToStation)).ToList(); List <Bus> bussesFirstFive = bussesSorted.GetRange(0, 5); foreach (var Bus in bussesFirstFive) { int minutes = Bus.TimeToStation / 60; Console.WriteLine(Bus.Towards + " " + minutes + " " + Bus.DestinationName); } Console.ReadLine(); }
private static string GetPredictionsForPostcode(TflApi tflApi, PostcodeApi postcodeApi, string postcode) { var postcodeData = postcodeApi.GetPostcodeData(postcode); return(GetPredictionsForLatLon(tflApi, postcodeData.latitude, postcodeData.longitude)); }