From 3aa6eee0f54dec3e4f92be2ad335a04145ac4db8 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> Date: Mon, 3 Mar 2025 18:54:35 +0100 Subject: Improve the UI --- Backend/GetStopList.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Backend/GetStopList.cs (limited to 'Backend') diff --git a/Backend/GetStopList.cs b/Backend/GetStopList.cs new file mode 100644 index 0000000..e3a1894 --- /dev/null +++ b/Backend/GetStopList.cs @@ -0,0 +1,31 @@ +using Microsoft.Azure.Functions.Worker; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Costasdev.VigoTransitApi; + +namespace Costasdev.UrbanoVigoWeb; + +public class GetStopList +{ + private readonly VigoTransitApiClient _api; + + public GetStopList(HttpClient http) + { + _api = new VigoTransitApiClient(http); + } + + [Function("GetStopList")] + public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req) + { + try + { + var stops = await _api.GetStops(); + return new OkObjectResult(stops); + } + catch (InvalidOperationException) + { + return new BadRequestObjectResult("Failed to retrieve stops"); + } + } +} + -- cgit v1.3