aboutsummaryrefslogtreecommitdiff
path: root/Backend/GetStopList.cs
diff options
context:
space:
mode:
authorAriel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>2025-03-03 18:54:35 +0100
committerAriel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>2025-03-03 18:54:35 +0100
commit3aa6eee0f54dec3e4f92be2ad335a04145ac4db8 (patch)
tree9ccffabd2972249322ebaa6d1de26289d7a41a4c /Backend/GetStopList.cs
parentd3726e50167ed07c483c542cf6739f103dda0dd5 (diff)
Improve the UI
Diffstat (limited to 'Backend/GetStopList.cs')
-rw-r--r--Backend/GetStopList.cs31
1 files changed, 31 insertions, 0 deletions
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<IActionResult> 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");
+ }
+ }
+}
+