From be0753281d8b4a482ebe34e7b82aa8bd3380a92b Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 26 Mar 2024 17:27:48 +0100 Subject: [PATCH] Fixed filtering by date interval. The lamba used to filter out arrivals/Departures was all wrong. --- src/BreCalClient/MainWindow.xaml.cs | 37 +++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index f9aaa80..c00efee 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -582,12 +582,45 @@ namespace BreCalClient if(sfm.EtaFrom != null) { - _ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta < sfm.EtaFrom); + _ = this._visibleControlModels.RemoveAll(x => + { + Times? t = x.GetTimesForParticipantType(ParticipantType.AGENCY); + switch (x.Shipcall?.Type) + { + case (int)Extensions.TypeEnum.Incoming: + { + if ((t != null) && t.EtaBerth.HasValue) return t.EtaBerth.Value < sfm.EtaFrom; + return x.Shipcall?.Eta < sfm.EtaFrom; + } + default: // Shifting / Departing + { + if ((t != null) && t.EtdBerth.HasValue) return t.EtdBerth.Value < sfm.EtaFrom; + return x.Shipcall?.Etd < sfm.EtaFrom; + } + } + }); } if(sfm.EtaTo != null) { - _ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta > sfm.EtaTo); + _ = this._visibleControlModels.RemoveAll(x => + { + Times? t = x.GetTimesForParticipantType(ParticipantType.AGENCY); + DateTime refValue = sfm.EtaTo.Value.AddMinutes(1439); // 23:59 + switch (x.Shipcall?.Type) + { + case (int)Extensions.TypeEnum.Incoming: + { + if ((t != null) && t.EtaBerth.HasValue) return t.EtaBerth.Value > refValue; + return x.Shipcall?.Eta > refValue; + } + default: // Shifting / Departing + { + if ((t != null) && t.EtdBerth.HasValue) return t.EtdBerth.Value > refValue; + return x.Shipcall?.Etd > refValue; + } + } + }); } if(!_showCanceled ?? true) // canceled calls are filtered by default