From dc20c2ba8377a90a3170642c9b3df6cd5166ad72 Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> Date: Sun, 25 Aug 2024 23:12:48 +0200 Subject: Initial commit --- Backend/ListStops.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Backend/ListStops.cs (limited to 'Backend/ListStops.cs') diff --git a/Backend/ListStops.cs b/Backend/ListStops.cs new file mode 100644 index 0000000..93b6a48 --- /dev/null +++ b/Backend/ListStops.cs @@ -0,0 +1,30 @@ +using Microsoft.Azure.Functions.Worker; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Costasdev.VigoTransitApi; + +namespace Costasdev.UrbanoVigoWeb; + +public class ListStops +{ + private readonly VigoTransitApiClient _api; + + public ListStops(HttpClient http) + { + _api = new VigoTransitApiClient(http); + } + + [Function("ListStops")] + 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("Stop not found"); + } + } +} -- cgit v1.3