Filter shipcalls that have ata set and ata is more than 2 hours in the past

This commit is contained in:
Daniel Schick 2024-06-28 10:47:27 +02:00
parent b275320d54
commit fe46b9b94e

View File

@ -640,7 +640,7 @@ namespace BreCalClient
// first add everything
this._visibleControlModels.AddRange(_allShipcallsDict.Values);
// now remove elements whose filter criteria are met
// now remove elements whose filter criteria are met
if(sfm.Berths.Count > 0 )
{
@ -745,7 +745,34 @@ namespace BreCalClient
_ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Canceled ?? false);
}
switch(this._sortOrder)
// special Basti case: Wenn das ATA / ATD eingetragen ist und schon 2 Stunden in der Vergangenheit liegt
if (searchPastDays <= 3)
{
_ = this._visibleControlModels.RemoveAll(x =>
{
Times? mooringTimes = x.GetTimesForParticipantType(ParticipantType.MOORING);
if (mooringTimes != null)
{
switch (x.Shipcall?.Type)
{
case ShipcallType.Arrival:
if (mooringTimes.Ata.HasValue && ((DateTime.Now - mooringTimes.Ata.Value).TotalHours > 2))
return true;
break;
default:
if (mooringTimes.Atd.HasValue && ((DateTime.Now - mooringTimes.Atd.Value).TotalHours > 2))
return true;
break;
}
}
return false;
});
}
switch (this._sortOrder)
{
case Extensions.SortOrder.SHIP_NAME:
this._visibleControlModels.Sort((x, y) => { if (x.Ship == null) return 0; if (y.Ship == null) return 0; return x.Ship.Name.CompareTo(y.Ship.Name); });