Cleanup
This commit is contained in:
parent
c7e0f6e84c
commit
803c390c81
1 changed files with 3 additions and 10 deletions
|
|
@ -32,7 +32,7 @@ public static class TransportConnectionCalculator
|
||||||
var validConnections = new List<TransportConnection>();
|
var validConnections = new List<TransportConnection>();
|
||||||
var lateValidConnections = new List<TransportConnection>();
|
var lateValidConnections = new List<TransportConnection>();
|
||||||
|
|
||||||
foreach (var connection in connections)
|
foreach (var connection in connections.OrderBy(c => c.ArrivalTime))
|
||||||
{
|
{
|
||||||
if (connection.ArrivalTime <= latestArrivalTime)
|
if (connection.ArrivalTime <= latestArrivalTime)
|
||||||
{
|
{
|
||||||
|
|
@ -47,10 +47,7 @@ public static class TransportConnectionCalculator
|
||||||
// If we have valid connections (arriving before latest arrival time)
|
// If we have valid connections (arriving before latest arrival time)
|
||||||
if (validConnections.Count > 0)
|
if (validConnections.Count > 0)
|
||||||
{
|
{
|
||||||
var bestValidConnection = validConnections
|
var bestValidConnection = validConnections.Last();
|
||||||
.OrderBy(c => c.ArrivalTime)
|
|
||||||
.Last();
|
|
||||||
|
|
||||||
if (bestValidConnection.ArrivalTime > earliestAcceptableTime)
|
if (bestValidConnection.ArrivalTime > earliestAcceptableTime)
|
||||||
{
|
{
|
||||||
return bestValidConnection;
|
return bestValidConnection;
|
||||||
|
|
@ -60,11 +57,7 @@ public static class TransportConnectionCalculator
|
||||||
// If no connections arrive before latest arrival time, check if any arrive within acceptable late range
|
// If no connections arrive before latest arrival time, check if any arrive within acceptable late range
|
||||||
if (lateValidConnections.Count > 0)
|
if (lateValidConnections.Count > 0)
|
||||||
{
|
{
|
||||||
var bestLateConnection = lateValidConnections
|
return lateValidConnections.First();
|
||||||
.OrderBy(c => c.ArrivalTime)
|
|
||||||
.First();
|
|
||||||
|
|
||||||
return bestLateConnection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return validConnections.FirstOrDefault();
|
return validConnections.FirstOrDefault();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue