public static async Task <IActionResult> GetStation( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "stations/{stationAbbreviation}")] HttpRequest req, string stationAbbreviation, ILogger log) { log.LogInformation($"Get station for '{stationAbbreviation}'"); LuasApi api = new LuasApi(); try { Station station = api.GetStation(stationAbbreviation); return(new OkObjectResult(station)); } catch (StationNotFoundException ex) { log.LogWarning($"StationNotFoundException for '{stationAbbreviation}'. Exception: {ex}"); return(new NotFoundObjectResult($"Unable to find station for: '{stationAbbreviation}'")); } catch (Exception ex) { log.LogError($"Unexpected code path '{stationAbbreviation}'. Exception: {ex}"); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }
static void Main() { LuasApi api = new LuasApi(); var s = api.GetStation("ABB"); //Console.WriteLine(JsonConvert.SerializeObject(api.GetAllStations())); //Console.WriteLine(); Console.WriteLine(JsonConvert.SerializeObject(api.GetForecast(s))); }