public ActionResult BusInfo(PostcodeSelection selection) { // Add some properties to the BusInfo view model with the data you want to render on the page. // Write code here to populate the view model with info from the APIs. // Then modify the view (in Views/Home/BusInfo.cshtml) to render upcoming buses. var postcode = new BusInfo(selection.Postcode); try { var coordinates = ApiFetcher.GetCoordinates(postcode.PostCode); var stopPoints = ApiFetcher.GetStopPoints(coordinates.result); var busStops = new List <BusStop>(); foreach (var stopPoint in stopPoints) { var buses = ApiFetcher.GetBuses(stopPoint); foreach (var bus in buses) { bus.timeToStation = bus.timeToStation / 60; } var busStop = new BusStop(buses, stopPoint.commonName); busStops.Add(busStop); } return(View(busStops)); } catch { return(View()); } }
static void Main(string[] args) { var postcode = UserInterface.GetPostcode(); var coordinates = ApiFetcher.GetCoordinates(postcode); var stopPoints = ApiFetcher.GetStopPoints(coordinates.result); foreach (var stopPoint in stopPoints) { var buses = ApiFetcher.GetBuses(stopPoint); UserInterface.ShowInformation(buses, stopPoint.commonName); } Console.ReadLine(); }