Fixed filtering by date interval.

The lamba used to filter out arrivals/Departures was all wrong.
This commit is contained in:
Daniel Schick 2024-03-26 17:27:48 +01:00
parent f311d75c73
commit 049cdaaf73

View File

@ -609,12 +609,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