Fixed an error regarding berth display in AGENT/TERMINAL and set to+from berth info for shifting shipcalls

This commit is contained in:
Daniel Schick 2024-07-11 11:39:12 +02:00
parent ec0eb3cbfa
commit 24138fc1e9

View File

@ -16,7 +16,7 @@ namespace BreCalClient
public class ShipcallControlModel public class ShipcallControlModel
{ {
#region Enumerations #region Enumerations
[Flags] [Flags]
public enum StatusFlags public enum StatusFlags
@ -146,28 +146,42 @@ namespace BreCalClient
return false; return false;
} }
/// <summary>
/// Get berth display text for columns AGENT and TERMINAL
/// </summary>
public string? GetBerthText(Times times) public string? GetBerthText(Times times)
{ {
string? timesBerthText = null;
string? scArrivalBerthText = null;
string? scDepartureBerthText = null;
string? berthText = null; string? berthText = null;
if ((BreCalLists.Berths != null) && times.BerthId.HasValue && (this.Shipcall?.Type != ShipcallType.Shifting)) Berth? berth;
if(times.BerthId.HasValue)
{ {
Berth? berth = BreCalLists.AllBerths.Find((x) => x.Id == times.BerthId); berth = BreCalLists.AllBerths.Find((x) => x.Id == times.BerthId.Value);
berthText = berth?.Name; timesBerthText = berth?.Name;
} }
if ((berthText == null) && (times.ParticipantType != (int) Extensions.ParticipantType.TERMINAL)) berth = BreCalLists.AllBerths?.Find((x) => x.Id == this.Shipcall?.ArrivalBerthId);
scArrivalBerthText = berth?.Name;
berth = BreCalLists.AllBerths?.Find((x) => x.Id == this.Shipcall?.DepartureBerthId);
scDepartureBerthText= berth?.Name;
switch(this.Shipcall?.Type)
{ {
if (this.Shipcall?.Type == ShipcallType.Arrival) case ShipcallType.Arrival:
{ berthText = timesBerthText ?? scArrivalBerthText;
Berth? berth = BreCalLists.AllBerths?.Find((x) => x.Id == this.Shipcall?.ArrivalBerthId); break;
berthText = berth?.Name; case ShipcallType.Departure:
} berthText = timesBerthText ?? scDepartureBerthText;
else break;
{ case ShipcallType.Shifting:
Berth? berth = BreCalLists.AllBerths?.Find((x) => x.Id == this.Shipcall?.DepartureBerthId); berthText = (scDepartureBerthText ?? "") + "-" + timesBerthText ?? scArrivalBerthText;
berthText = berth?.Name; break;
} default: break;
} }
return berthText; return berthText;
} }
@ -194,7 +208,7 @@ namespace BreCalClient
{ {
if (agentTimes.EtdBerth != null) if (agentTimes.EtdBerth != null)
theDate = agentTimes.EtdBerth.Value; theDate = agentTimes.EtdBerth.Value;
} }
} }
return theDate.ToString(); return theDate.ToString();
} }