diff --git a/Services/TransportApiService.cs b/Services/TransportApiService.cs index 15ffd72..c6e579e 100644 --- a/Services/TransportApiService.cs +++ b/Services/TransportApiService.cs @@ -1,9 +1,10 @@ using System.Text.Json; +using Microsoft.Extensions.Logging; using ShiftScheduler.Shared; namespace ShiftScheduler.Services { - public class TransportApiService(HttpClient httpClient, IConfigurationService configurationService) : ITransportApiService + public class TransportApiService(HttpClient httpClient, IConfigurationService configurationService, ILogger logger) : ITransportApiService { public async Task GetConnectionAsync(DateTime shiftStartTime) { @@ -24,12 +25,22 @@ namespace ShiftScheduler.Services if (apiResponse?.Connections.Count > 0) { var allConnections = apiResponse.Connections.Select(MapToTransportConnection).ToList(); - return TransportConnectionCalculator.FindBestConnection( + + foreach (var connection in allConnections) + { + logger.LogInformation($"Found connection {connection}"); + } + + var bestConnection = TransportConnectionCalculator.FindBestConnection( allConnections, shiftStartTime, config.SafetyBufferMinutes, config.MaxEarlyArrivalMinutes, config.MaxLateArrivalMinutes); + + logger.LogInformation($"Found best {bestConnection}"); + + return bestConnection; } return null; diff --git a/Shared/TransportModels.cs b/Shared/TransportModels.cs index 311a684..66fa378 100644 --- a/Shared/TransportModels.cs +++ b/Shared/TransportModels.cs @@ -19,6 +19,11 @@ namespace ShiftScheduler.Shared public string Duration { get; set; } = string.Empty; public string? Platform { get; set; } = string.Empty; public List Sections { get; set; } = new(); + + public override string ToString() + { + return $"{Platform}: {DepartureTime} - {ArrivalTime} ({Duration})"; + } } public class TransportSection