From 24138fc1e9fbfb0e84774161b7d6a3a41e848521 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 11 Jul 2024 11:39:12 +0200 Subject: [PATCH] Fixed an error regarding berth display in AGENT/TERMINAL and set to+from berth info for shifting shipcalls --- src/BreCalClient/ShipcallControlModel.cs | 48 +++++++++++++++--------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/src/BreCalClient/ShipcallControlModel.cs b/src/BreCalClient/ShipcallControlModel.cs index 5b2a2b6..4d34de7 100644 --- a/src/BreCalClient/ShipcallControlModel.cs +++ b/src/BreCalClient/ShipcallControlModel.cs @@ -16,7 +16,7 @@ namespace BreCalClient public class ShipcallControlModel { - #region Enumerations + #region Enumerations [Flags] public enum StatusFlags @@ -146,28 +146,42 @@ namespace BreCalClient return false; } + /// + /// Get berth display text for columns AGENT and TERMINAL + /// public string? GetBerthText(Times times) { + string? timesBerthText = null; + string? scArrivalBerthText = null; + string? scDepartureBerthText = 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); - berthText = berth?.Name; + berth = BreCalLists.AllBerths.Find((x) => x.Id == times.BerthId.Value); + 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) - { - Berth? berth = BreCalLists.AllBerths?.Find((x) => x.Id == this.Shipcall?.ArrivalBerthId); - berthText = berth?.Name; - } - else - { - Berth? berth = BreCalLists.AllBerths?.Find((x) => x.Id == this.Shipcall?.DepartureBerthId); - berthText = berth?.Name; - } - } + case ShipcallType.Arrival: + berthText = timesBerthText ?? scArrivalBerthText; + break; + case ShipcallType.Departure: + berthText = timesBerthText ?? scDepartureBerthText; + break; + case ShipcallType.Shifting: + berthText = (scDepartureBerthText ?? "") + "-" + timesBerthText ?? scArrivalBerthText; + break; + default: break; + } return berthText; } @@ -194,7 +208,7 @@ namespace BreCalClient { if (agentTimes.EtdBerth != null) theDate = agentTimes.EtdBerth.Value; - } + } } return theDate.ToString(); }