From 6a7d211fcc8a94e3d51e006b1cfefb1f05483bec Mon Sep 17 00:00:00 2001 From: gilad-teller Date: Tue, 27 Feb 2024 12:25:30 +0200 Subject: [PATCH] fix(Route): handle null reference in train delay calculation --- IsraelRail/IsraelRail/Models/ViewModels/Route.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IsraelRail/IsraelRail/Models/ViewModels/Route.cs b/IsraelRail/IsraelRail/Models/ViewModels/Route.cs index ea77da2..8dc8584 100644 --- a/IsraelRail/IsraelRail/Models/ViewModels/Route.cs +++ b/IsraelRail/IsraelRail/Models/ViewModels/Route.cs @@ -139,7 +139,7 @@ public async Task> BuildRoutes(TimetableResult timetable) }; if (apiTrain.TrainPosition != null) { - train.Delay = TimeSpan.FromMinutes(travel.Trains[0].TrainPosition.CalcDiffMinutes); + train.Delay = TimeSpan.FromMinutes(travel?.Trains[0]?.TrainPosition?.CalcDiffMinutes ?? 0); } foreach (RouteStation routeStation in apiTrain.RouteStations) {