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 @@
-
-
-
-
-
+
diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs
index b0865bd..a087172 100644
--- a/src/BreCalClient/ShipcallControl.xaml.cs
+++ b/src/BreCalClient/ShipcallControl.xaml.cs
@@ -151,6 +151,21 @@ namespace BreCalClient
break;
}
+ switch(this.ShipcallControlModel?.LightMode)
+ {
+ case ShipcallControlModel.TrafficLightMode.GREEN:
+ this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/check.png"));
+ break;
+ case ShipcallControlModel.TrafficLightMode.YELLOW:
+ this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/sign_warning.png"));
+ break;
+ case ShipcallControlModel.TrafficLightMode.RED:
+ this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/delete2.png"));
+ break;
+ default:
+ break;
+ }
+
if (this.ShipcallControlModel?.Shipcall?.Evaluation != null)
{
ShipcallControlModel.TrafficLightMode resultColor = (ShipcallControlModel.TrafficLightMode) (this.ShipcallControlModel?.Shipcall?.Evaluation ?? 0); // der nullable Operator hier ist so doof, die VS validation blickts einfach nicht
@@ -280,6 +295,7 @@ namespace BreCalClient
if (times.ParticipantType == (int)Extensions.ParticipantType.TERMINAL)
{
+ this.labelTerminalBerth.Content = berthText;
this.labelOperationsStart.Content = times.OperationsStart.HasValue ? times.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
this.textBlockTerminalRemarks.Text = times.Remarks;
if (this.ShipcallControlModel?.Shipcall?.Type != 1)
diff --git a/src/BreCalClient/ShipcallControlModel.cs b/src/BreCalClient/ShipcallControlModel.cs
index 5685733..a5e8e73 100644
--- a/src/BreCalClient/ShipcallControlModel.cs
+++ b/src/BreCalClient/ShipcallControlModel.cs
@@ -2,6 +2,7 @@
// Description: Container model for shipcall related info
//
+using BreCalClient.misc.Api;
using BreCalClient.misc.Model;
using System;
using System.Collections.Generic;
@@ -124,6 +125,25 @@ namespace BreCalClient
return false;
}
+ ///
+ /// After closing the edit shipcall or edit agency dialogs, the times assignments may have changed.
+ /// This function updates the assignments for existing times records accordingly and saves them.
+ ///
+ /// API reference to PUT eidted times
+ internal async void UpdateTimesAssignments(DefaultApi _api)
+ {
+ foreach (Extensions.ParticipantType participantType in this.AssignedParticipants.Keys)
+ {
+ Times? times = this.GetTimesForParticipantType(participantType);
+ if(times == null) continue;
+ if(times.ParticipantId != this.AssignedParticipants[participantType].ParticipantId)
+ {
+ times.ParticipantId = this.AssignedParticipants[participantType].ParticipantId;
+ await _api.TimesPutAsync(times);
+ }
+ }
+ }
+
#endregion
#region helper