* Initial plan * Implement transport time improvements: departure station display and break time logic Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> * Enhance code --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: clayschaad <11883505+clayschaad@users.noreply.github.com> Co-authored-by: Claudio Schaad <c.schaad@pog.ch>
34 lines
No EOL
1.5 KiB
C#
34 lines
No EOL
1.5 KiB
C#
namespace ShiftScheduler.Shared.Models
|
|
{
|
|
// View model that combines shift information with transport data for a specific date
|
|
public record ShiftWithTransport
|
|
{
|
|
public DateTime Date { get; init; }
|
|
public Shift Shift { get; init; } = new();
|
|
public TransportConnection? MorningTransport { get; init; }
|
|
public TransportConnection? AfternoonTransport { get; init; }
|
|
|
|
public string GetMorningTransportSummary()
|
|
{
|
|
return MorningTransport != null ? FormatTransportSummary(MorningTransport) : string.Empty;
|
|
}
|
|
|
|
public string GetAfternoonTransportSummary()
|
|
{
|
|
return AfternoonTransport != null ? FormatTransportSummary(AfternoonTransport) : string.Empty;
|
|
}
|
|
|
|
private string FormatTransportSummary(TransportConnection connection)
|
|
{
|
|
if (string.IsNullOrEmpty(connection.DepartureTime)) return string.Empty;
|
|
|
|
var departure = DateTime.TryParse(connection.DepartureTime, out var dep) ? dep.ToString("HH:mm") : connection.DepartureTime;
|
|
var arrival = DateTime.TryParse(connection.ArrivalTime, out var arr) ? arr.ToString("HH:mm") : connection.ArrivalTime;
|
|
|
|
var mainJourney = connection.Sections?.FirstOrDefault()?.Journey;
|
|
var trainInfo = mainJourney != null ? $"{mainJourney.Category}{mainJourney.Number}" : "Train";
|
|
|
|
return $"{trainInfo} {departure}→{arrival}";
|
|
}
|
|
}
|
|
} |