From 9c690a91b0a5d5a3d2a3285da880b399b433f6d9 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Sun, 22 Oct 2023 13:08:15 +0200 Subject: [PATCH] Fixes for tests regarding the evaluation functions --- .../EditTimesAgencyIncomingControl.xaml.cs | 8 +++----- .../EditTimesAgencyOutgoingControl.xaml.cs | 7 +++---- .../EditTimesAgencyShiftingControl.xaml.cs | 8 +++----- src/BreCalClient/MainWindow.xaml.cs | 15 +++++++++++++- src/BreCalClient/ShipcallControl.xaml | 19 +----------------- src/BreCalClient/ShipcallControl.xaml.cs | 16 +++++++++++++++ src/BreCalClient/ShipcallControlModel.cs | 20 +++++++++++++++++++ 7 files changed, 60 insertions(+), 33 deletions(-) diff --git a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs index e9b584a..b488d3e 100644 --- a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs @@ -92,11 +92,9 @@ namespace BreCalClient { this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPierside.SelectedIndex == 0) ? true : false; } - this.Times.BerthInfo = this.textBoxBerthRemarks.Text.Trim(); - if((this.comboBoxArrivalBerth.SelectedValue != null) && ((int?)this.comboBoxArrivalBerth.SelectedValue != this.ShipcallModel.Shipcall.ArrivalBerthId)) - { - this.Times.BerthId = (int?)this.comboBoxArrivalBerth.SelectedValue; - } + + this.Times.BerthInfo = this.textBoxBerthRemarks.Text.Trim(); + this.Times.BerthId = (int?)this.comboBoxArrivalBerth.SelectedValue; this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value; this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value; diff --git a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs index b697ebd..6117df4 100644 --- a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs @@ -89,10 +89,9 @@ namespace BreCalClient { this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPierside.SelectedIndex == 0) ? true : false; } - if ((this.comboBoxDepartureBerth.SelectedValue != null) && ((int?)this.comboBoxDepartureBerth.SelectedValue != this.ShipcallModel.Shipcall.DepartureBerthId)) - { - this.Times.BerthId = (int?)this.comboBoxDepartureBerth.SelectedValue; - } + + this.Times.BerthId = (int?)this.comboBoxDepartureBerth.SelectedValue; + this.Times.BerthInfo = this.textBoxBerthRemarks.Text.Trim(); this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value; this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value; diff --git a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs index beb7e04..0bb4f61 100644 --- a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs @@ -92,11 +92,9 @@ namespace BreCalClient { this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPiersideArrival.SelectedIndex == 0) ? true : false; } - this.Times.BerthInfo = this.textBoxBerthRemarksArrival.Text.Trim(); - if ((this.comboBoxArrivalBerth.SelectedValue != null) && ((int?)this.comboBoxArrivalBerth.SelectedValue != this.ShipcallModel.Shipcall.ArrivalBerthId)) - { - this.Times.BerthId = (int?)this.comboBoxArrivalBerth.SelectedValue; - } + + this.Times.BerthInfo = this.textBoxBerthRemarksArrival.Text.Trim(); + this.Times.BerthId = (int?)this.comboBoxArrivalBerth.SelectedValue; this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value; this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value; diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index 49aae06..6df2daf 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -507,10 +507,12 @@ namespace BreCalClient } } - + #endregion + #region UpdateUI func + private void UpdateUI() { @@ -542,6 +544,8 @@ namespace BreCalClient })); } + #endregion + #region control event handler private async void Sc_EditRequested(ShipcallControl obj) @@ -558,6 +562,7 @@ namespace BreCalClient try { obj.ShipcallControlModel.Shipcall?.Participants.Clear(); + obj.ShipcallControlModel.UpdateTimesAssignments(this._api); foreach(ParticipantAssignment pa in obj.ShipcallControlModel.AssignedParticipants.Values) obj.ShipcallControlModel.Shipcall?.Participants.Add(pa); await _api.ShipcallsPutAsync(obj.ShipcallControlModel.Shipcall); @@ -584,6 +589,7 @@ namespace BreCalClient if(obj.ShipcallControlModel.Shipcall != null) etc.CallType = (TypeEnum) obj.ShipcallControlModel.Shipcall.Type; + bool wasEdit = false; if (times != null) { @@ -654,12 +660,19 @@ namespace BreCalClient { editControl.Times = times; wasEdit = true; + } + else + { + if(editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) + editControl.Times.ParticipantId = editControl.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId; } editControl.Times.ParticipantType = (int)ParticipantType.AGENCY; if(editControl.ShowDialog() ?? false) { try { + sc.ShipcallControlModel?.UpdateTimesAssignments(_api); // if the agent changed the assignment of the participant to another + // always try to be the agent, even if we are BSMD if (editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) { diff --git a/src/BreCalClient/ShipcallControl.xaml b/src/BreCalClient/ShipcallControl.xaml index a81e73a..913e936 100644 --- a/src/BreCalClient/ShipcallControl.xaml +++ b/src/BreCalClient/ShipcallControl.xaml @@ -48,24 +48,7 @@