fixed removing of assignments (delete times record), removed green bg color

This commit is contained in:
Daniel Schick 2023-11-10 11:36:17 +01:00
parent b7a8b3aa1b
commit d439b7ed12
3 changed files with 72 additions and 11 deletions

View File

@ -65,14 +65,6 @@
<ColumnDefinition Width=".5*" />
<ColumnDefinition Width=".5*" />
</Grid.ColumnDefinitions>
<ComboBox Name="comboBoxDepartureBerth" Grid.Column="1" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemArrivalBerth" Click="contextMenuItemArrivalBerth_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<ComboBox Name="comboBoxArrivalBerth" Grid.Column="0" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
@ -80,6 +72,13 @@
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
<ComboBox Name="comboBoxDepartureBerth" Grid.Column="1" Margin="2" DisplayMemberPath="Name" SelectedValuePath="Id">
<ComboBox.ContextMenu>
<ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemArrivalBerth" Click="contextMenuItemArrivalBerth_Click" />
</ContextMenu>
</ComboBox.ContextMenu>
</ComboBox>
</Grid>
<xctk:DateTimePicker x:Name="datePickerETA" Grid.Column="3" Grid.Row="2" Margin="2" Format="Custom" FormatString="dd.MM. yyyy HH:mm" IsEnabled="False"/>

View File

@ -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;

View File

@ -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<Times> 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