Remove sections from transport model
This commit is contained in:
parent
385e9f90fe
commit
cc81cacda8
5 changed files with 1 additions and 79 deletions
|
|
@ -71,12 +71,6 @@ namespace ShiftScheduler.Services
|
||||||
var departure = DateTime.TryParse(transport.DepartureTime, out var dep) ? dep.ToString("HH:mm") : transport.DepartureTime;
|
var departure = DateTime.TryParse(transport.DepartureTime, out var dep) ? dep.ToString("HH:mm") : transport.DepartureTime;
|
||||||
var arrival = DateTime.TryParse(transport.ArrivalTime, out var arr) ? arr.ToString("HH:mm") : transport.ArrivalTime;
|
var arrival = DateTime.TryParse(transport.ArrivalTime, out var arr) ? arr.ToString("HH:mm") : transport.ArrivalTime;
|
||||||
|
|
||||||
var mainJourney = transport.Sections?.FirstOrDefault()?.Journey;
|
|
||||||
if (mainJourney != null)
|
|
||||||
{
|
|
||||||
return $"{mainJourney.Category} {mainJourney.Number}: {departure} → {arrival}";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $"{departure} → {arrival}";
|
return $"{departure} → {arrival}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,37 +51,6 @@ namespace ShiftScheduler.Services
|
||||||
ArrivalTime = apiConnection.To?.Arrival ?? string.Empty,
|
ArrivalTime = apiConnection.To?.Arrival ?? string.Empty,
|
||||||
Duration = apiConnection.Duration,
|
Duration = apiConnection.Duration,
|
||||||
Platform = apiConnection.From?.Platform ?? string.Empty,
|
Platform = apiConnection.From?.Platform ?? string.Empty,
|
||||||
Sections = apiConnection.Sections.Select(s => new TransportSection
|
|
||||||
{
|
|
||||||
Journey = s.Journey != null ? new TransportJourney
|
|
||||||
{
|
|
||||||
Name = s.Journey.Name,
|
|
||||||
Category = s.Journey.Category,
|
|
||||||
Number = s.Journey.Number
|
|
||||||
} : null,
|
|
||||||
Departure = s.Departure != null ? new TransportCheckpoint
|
|
||||||
{
|
|
||||||
Station = s.Departure.Station != null ? new TransportStation
|
|
||||||
{
|
|
||||||
Name = s.Departure.Station.Name,
|
|
||||||
Id = s.Departure.Station.Id
|
|
||||||
} : null,
|
|
||||||
Departure = s.Departure.Departure,
|
|
||||||
Arrival = s.Departure.Arrival,
|
|
||||||
Platform = s.Departure.Platform
|
|
||||||
} : null,
|
|
||||||
Arrival = s.Arrival != null ? new TransportCheckpoint
|
|
||||||
{
|
|
||||||
Station = s.Arrival.Station != null ? new TransportStation
|
|
||||||
{
|
|
||||||
Name = s.Arrival.Station.Name,
|
|
||||||
Id = s.Arrival.Station.Id
|
|
||||||
} : null,
|
|
||||||
Departure = s.Arrival.Departure,
|
|
||||||
Arrival = s.Arrival.Arrival,
|
|
||||||
Platform = s.Arrival.Platform
|
|
||||||
} : null
|
|
||||||
}).ToList()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
namespace ShiftScheduler.Shared
|
namespace ShiftScheduler.Shared
|
||||||
{
|
{
|
||||||
// View model that combines shift information with transport data for a specific date
|
|
||||||
public record ShiftWithTransport
|
public record ShiftWithTransport
|
||||||
{
|
{
|
||||||
public DateTime Date { get; init; }
|
public DateTime Date { get; init; }
|
||||||
|
|
@ -24,11 +23,7 @@ namespace ShiftScheduler.Shared
|
||||||
|
|
||||||
var departure = DateTime.TryParse(connection.DepartureTime, out var dep) ? dep.ToString("HH:mm") : connection.DepartureTime;
|
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 arrival = DateTime.TryParse(connection.ArrivalTime, out var arr) ? arr.ToString("HH:mm") : connection.ArrivalTime;
|
||||||
|
return $"{departure}→{arrival}";
|
||||||
var mainJourney = connection.Sections?.FirstOrDefault()?.Journey;
|
|
||||||
var trainInfo = mainJourney != null ? $"{mainJourney.Category}{mainJourney.Number}" : "Train";
|
|
||||||
|
|
||||||
return $"{trainInfo} {departure}→{arrival}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -27,39 +27,10 @@ namespace ShiftScheduler.Shared
|
||||||
public string ArrivalTime { get; set; } = string.Empty;
|
public string ArrivalTime { get; set; } = string.Empty;
|
||||||
public string Duration { get; set; } = string.Empty;
|
public string Duration { get; set; } = string.Empty;
|
||||||
public string? Platform { get; set; } = string.Empty;
|
public string? Platform { get; set; } = string.Empty;
|
||||||
public List<TransportSection> Sections { get; set; } = new();
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"{Platform}: {DepartureTime} - {ArrivalTime} ({Duration})";
|
return $"{Platform}: {DepartureTime} - {ArrivalTime} ({Duration})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TransportSection
|
|
||||||
{
|
|
||||||
public TransportJourney? Journey { get; set; }
|
|
||||||
public TransportCheckpoint? Departure { get; set; }
|
|
||||||
public TransportCheckpoint? Arrival { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TransportJourney
|
|
||||||
{
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
public string Category { get; set; } = string.Empty;
|
|
||||||
public string Number { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TransportCheckpoint
|
|
||||||
{
|
|
||||||
public TransportStation? Station { get; set; }
|
|
||||||
public string? Departure { get; set; } = string.Empty;
|
|
||||||
public string? Arrival { get; set; } = string.Empty;
|
|
||||||
public string? Platform { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TransportStation
|
|
||||||
{
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
public string Id { get; set; } = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -62,13 +62,6 @@ public class TransportApiServiceTests
|
||||||
result.ArrivalTime.ShouldBe("2023-12-15T07:30:00");
|
result.ArrivalTime.ShouldBe("2023-12-15T07:30:00");
|
||||||
result.Duration.ShouldBe("00:45:00");
|
result.Duration.ShouldBe("00:45:00");
|
||||||
result.Platform.ShouldBe("5");
|
result.Platform.ShouldBe("5");
|
||||||
result.Sections.ShouldNotBeEmpty();
|
|
||||||
result.Sections.Count.ShouldBe(1);
|
|
||||||
|
|
||||||
var section = result.Sections.First();
|
|
||||||
section.Journey?.Name.ShouldBe("IC 1");
|
|
||||||
section.Journey?.Category.ShouldBe("IC");
|
|
||||||
section.Journey?.Number.ShouldBe("1");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue