aboutsummaryrefslogtreecommitdiff
path: root/Backend/ListStops.cs
diff options
context:
space:
mode:
authorAriel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>2024-08-30 16:26:19 +0200
committerAriel Costas Guerrero <94913521+arielcostas@users.noreply.github.com>2024-08-30 16:26:19 +0200
commitf1db052266f254dec65435a54702ca6e2a74a8cd (patch)
tree879b5dfc9d6c050a0fb12079bc5196d1ef1495ff /Backend/ListStops.cs
parent2656a9c1ed802f87d30530f6cea502a3238880de (diff)
Fix client-side stop list cache
Diffstat (limited to 'Backend/ListStops.cs')
-rw-r--r--Backend/ListStops.cs9
1 files changed, 9 insertions, 0 deletions
diff --git a/Backend/ListStops.cs b/Backend/ListStops.cs
index 93b6a48..b6f9ab4 100644
--- a/Backend/ListStops.cs
+++ b/Backend/ListStops.cs
@@ -2,6 +2,7 @@ using Microsoft.Azure.Functions.Worker;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Costasdev.VigoTransitApi;
+using Costasdev.VigoTransitApi.Types;
namespace Costasdev.UrbanoVigoWeb;
@@ -9,6 +10,8 @@ public class ListStops
{
private readonly VigoTransitApiClient _api;
+ public List<Stop>? Stops { get; set; } = null;
+
public ListStops(HttpClient http)
{
_api = new VigoTransitApiClient(http);
@@ -17,6 +20,12 @@ public class ListStops
[Function("ListStops")]
public async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req)
{
+ // Get stops from cache
+ if (Stops != null)
+ {
+ return new OkObjectResult(Stops);
+ }
+
try
{
var stops = await _api.GetStops();