From d439b7ed1275ed7bcc81af80e5ac4b13da7ed400 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 10 Nov 2023 11:36:17 +0100 Subject: [PATCH] fixed removing of assignments (delete times record), removed green bg color --- src/BreCalClient/EditShipcallControl.xaml | 15 ++++----- src/BreCalClient/ShipcallControl.xaml.cs | 41 +++++++++++++++++++++-- src/BreCalClient/ShipcallControlModel.cs | 27 +++++++++++++++ 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/src/BreCalClient/EditShipcallControl.xaml b/src/BreCalClient/EditShipcallControl.xaml index 0ed9c54..8f20e1b 100644 --- a/src/BreCalClient/EditShipcallControl.xaml +++ b/src/BreCalClient/EditShipcallControl.xaml @@ -65,14 +65,6 @@ - - - - - - - - @@ -80,6 +72,13 @@ + + + + + + + diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs index eb74cc7..b9f016e 100644 --- a/src/BreCalClient/ShipcallControl.xaml.cs +++ b/src/BreCalClient/ShipcallControl.xaml.cs @@ -71,26 +71,61 @@ namespace BreCalClient name = _agency?.Name; if (name != null) agentName = name; this.labelAgent.Content = name ?? "- / -"; + if(_agency == null) + { + // clear agency display controls + this.labelAgencyBerth.Content = ""; + this.labelAgencyETAETDValue.Content = ""; + this.textBlockAgencyRemarks.Text = ""; + this.textBlockAgencyBerthRemarks.Text = ""; + } _mooring = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.MOORING); name = _mooring?.Name; this.labelMooring.Content = name ?? "- / -"; + if(_mooring == null) + { + this.labelMooringETAETDValue.Content = ""; + this.textBlockMooringRemarks.Text = ""; + } _pilot = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.PILOT); name = _pilot?.Name; this.labelPilot.Content = name ?? "- / - "; + if(_pilot == null) + { + this.labelPilotETAETDValue.Content = ""; + this.textBlockPilotRemarks.Text = ""; + } _tug = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.TUG); name = _tug?.Name; this.labelTug.Content = name ?? "- / - "; + if(_tug == null) + { + this.labelTugETAETDValue.Content = ""; + this.textBlockTugRemarks.Text = ""; + } _port_administration = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.PORT_ADMINISTRATION); name = _port_administration?.Name; this.labelPortAuthority.Content = name ?? "- / - "; + if(_port_administration == null) + { + this.labelPortAuthorityETAETDValue.Content = ""; + this.textBlockPortAuthorityRemarks.Text = ""; + } _terminal = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.TERMINAL); name = _terminal?.Name; this.labelTerminal.Content = name ?? "- / - "; + if(_terminal == null) + { + this.textBlockTerminalRemarks.Text = ""; + this.textBlockTerminalBerthRemarks.Text = ""; + this.labelTerminalBerth.Content = ""; + this.labelOperationsStart.Content = ""; + } if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == _terminal?.Id)) { @@ -171,9 +206,9 @@ namespace BreCalClient ShipcallControlModel.TrafficLightMode resultColor = (ShipcallControlModel.TrafficLightMode) (this.ShipcallControlModel?.Shipcall?.Evaluation ?? 0); // der nullable Operator hier ist so doof, die VS validation blickts einfach nicht switch (resultColor) { - case ShipcallControlModel.TrafficLightMode.GREEN: - this.Background = Brushes.LightGreen; - break; + //case ShipcallControlModel.TrafficLightMode.GREEN: + // this.Background = Brushes.LightGreen; + // break; case ShipcallControlModel.TrafficLightMode.YELLOW: this.Background= Brushes.LightYellow; break; diff --git a/src/BreCalClient/ShipcallControlModel.cs b/src/BreCalClient/ShipcallControlModel.cs index a5e8e73..64610ba 100644 --- a/src/BreCalClient/ShipcallControlModel.cs +++ b/src/BreCalClient/ShipcallControlModel.cs @@ -142,6 +142,33 @@ namespace BreCalClient await _api.TimesPutAsync(times); } } + + // if somebody just removed an assignment it is gone fom AssignedParticipants, but there is still a + // times record left which must be removed + + List deleteTimes = new(); + foreach (Times times in this.Times) + { + bool foundTimes = false; + foreach (ParticipantAssignment pa in this.AssignedParticipants.Values) + { + if((pa.ParticipantId == times.ParticipantId) && (pa.Type == times.ParticipantType)) + { + foundTimes = true; + break; + } + } + if (!foundTimes) + { + deleteTimes.Add(times); + } + } + + foreach(Times times in deleteTimes) + { + _api.TimesDelete(times.Id); + this.Times.Remove(times); + } } #endregion