From 305cc0d3e1f4fd97c9820dba34d570e53d421bca Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 15 Dec 2023 16:58:50 +0100 Subject: [PATCH] only undeleted berths and ships to select, but display all --- src/BreCalClient/BreCalLists.cs | 28 ++++++++++++++++++++---- src/BreCalClient/ShipcallControlModel.cs | 8 +++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/BreCalClient/BreCalLists.cs b/src/BreCalClient/BreCalLists.cs index c8df918..49ddbe8 100644 --- a/src/BreCalClient/BreCalLists.cs +++ b/src/BreCalClient/BreCalLists.cs @@ -21,8 +21,10 @@ namespace BreCalClient private static readonly List terList = new(); private static List _berths = new(); + private static List _allBerths = new(); private static List _participants = new(); private static List _ships = new(); + private static List _allShips = new(); private readonly static ConcurrentDictionary _shipLookupDict = new(); private readonly static ConcurrentDictionary _berthLookupDict = new(); @@ -69,15 +71,25 @@ namespace BreCalClient public static List Participants { get { return _participants; } } /// - /// All berths + /// All active berths /// public static List Berths { get { return _berths; } } /// - /// All ships + /// All active berths + /// + public static List AllBerths { get { return _allBerths; } } + + /// + /// All active ships /// public static List Ships { get { return _ships; } } + /// + /// All active berths + /// + public static List AllShips { get { return _allShips; } } + #endregion #region methods @@ -106,15 +118,23 @@ namespace BreCalClient internal static void InitializeBerths(List berths) { foreach (var berth in berths) + { _berthLookupDict[berth.Id] = berth; - _berths = berths; + if(!berth.Deleted) + _berths.Add(berth); + } + _allBerths = berths; } internal static void InitializeShips(List ships) { foreach (var ship in ships) + { _shipLookupDict[ship.Id] = ship; - _ships = ships; + if (!ship.Deleted) + _ships.Add(ship); + } + _allShips = ships; } #endregion diff --git a/src/BreCalClient/ShipcallControlModel.cs b/src/BreCalClient/ShipcallControlModel.cs index d29a0ef..18d89f7 100644 --- a/src/BreCalClient/ShipcallControlModel.cs +++ b/src/BreCalClient/ShipcallControlModel.cs @@ -160,9 +160,9 @@ namespace BreCalClient public string? GetBerthText(Times times) { string? berthText = null; - if ((BreCalLists.Berths != null) && times.BerthId.HasValue && (this.Shipcall?.Type != (int)Extensions.TypeEnum.Shifting)) + if ((BreCalLists.AllBerths != null) && times.BerthId.HasValue && (this.Shipcall?.Type != (int)Extensions.TypeEnum.Shifting)) { - Berth? berth = BreCalLists.Berths.Find((x) => x.Id == times.BerthId); + Berth? berth = BreCalLists.AllBerths.Find((x) => x.Id == times.BerthId); berthText = berth?.Name; } @@ -170,12 +170,12 @@ namespace BreCalClient { if (this.Shipcall?.Type == (int)Extensions.TypeEnum.Incoming) { - Berth? berth = BreCalLists.Berths?.Find((x) => x.Id == this.Shipcall?.ArrivalBerthId); + Berth? berth = BreCalLists.AllBerths?.Find((x) => x.Id == this.Shipcall?.ArrivalBerthId); berthText = berth?.Name; } else { - Berth? berth = BreCalLists.Berths?.Find((x) => x.Id == this.Shipcall?.DepartureBerthId); + Berth? berth = BreCalLists.AllBerths?.Find((x) => x.Id == this.Shipcall?.DepartureBerthId); berthText = berth?.Name; } }