diff --git a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs index 142db76..0ea0444 100644 --- a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs @@ -4,7 +4,6 @@ using BreCalClient.misc.Model; using System; -using System.Runtime.Serialization; using System.Windows; using static BreCalClient.Extensions; @@ -41,23 +40,28 @@ namespace BreCalClient #region event handler private void Window_Loaded(object sender, RoutedEventArgs e) - { - this.comboBoxMooring.ItemsSource = BreCalLists.Participants_Mooring; - this.comboBoxPilot.ItemsSource = BreCalLists.Participants_Pilot; - this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug; - this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal; + { if ((this.ShipcallModel != null) && (this.ShipcallModel.Shipcall != null)) - this.comboBoxArrivalBerth.ItemsSource = BreCalLists.GetBerthsByPort(this.ShipcallModel.Shipcall.PortId); - else - this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths; + { + int portId = this.ShipcallModel.Shipcall.PortId; + this.comboBoxArrivalBerth.ItemsSource = BreCalLists.GetBerthsByPort(portId); + this.comboBoxMooring.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.MOORING); + this.comboBoxPilot.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.PILOT); + this.comboBoxTug.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.TUG); + this.comboBoxTerminal.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.TERMINAL); + } + this.CopyToControls(); this.Title = this.ShipcallModel?.Title; Participant? p = null; - if(this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) - p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId); + if (this.ShipcallModel != null) + { + if (this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) + p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId); + } bool allowBSMD = false; if (p != null) diff --git a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs index 27d669f..45159c2 100644 --- a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs @@ -48,24 +48,28 @@ namespace BreCalClient #region event handler private void Window_Loaded(object sender, RoutedEventArgs e) - { - this.comboBoxMooring.ItemsSource = BreCalLists.Participants_Mooring; - this.comboBoxPilot.ItemsSource = BreCalLists.Participants_Pilot; - this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug; - this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal; + { if ((this.ShipcallModel != null) && (this.ShipcallModel.Shipcall != null)) - this.comboBoxDepartureBerth.ItemsSource = BreCalLists.GetBerthsByPort(this.ShipcallModel.Shipcall.PortId); - else - this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths; + { + int portId = this.ShipcallModel.Shipcall.PortId; + this.comboBoxDepartureBerth.ItemsSource = BreCalLists.GetBerthsByPort(portId); + this.comboBoxMooring.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.MOORING); + this.comboBoxPilot.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.PILOT); + this.comboBoxTug.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.TUG); + this.comboBoxTerminal.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.TERMINAL); + } + this.CopyToControls(); this.Title = this.ShipcallModel?.Title; Participant? p = null; - if (this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) - p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId); - + if (this.ShipcallModel != null) + { + if (this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) + p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId); + } bool allowBSMD = false; if (p != null) { diff --git a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs index d9517e3..592fd9d 100644 --- a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs @@ -42,31 +42,30 @@ namespace BreCalClient #region event handler private void Window_Loaded(object sender, RoutedEventArgs e) - { - this.comboBoxMooring.ItemsSource = BreCalLists.Participants_Mooring; - this.comboBoxPilot.ItemsSource = BreCalLists.Participants_Pilot; - this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug; - this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal; + { if ((this.ShipcallModel != null) && (this.ShipcallModel.Shipcall != null)) { - List availableBerths = BreCalLists.GetBerthsByPort(this.ShipcallModel.Shipcall.PortId); + int portId = this.ShipcallModel.Shipcall.PortId; + List availableBerths = BreCalLists.GetBerthsByPort(portId); this.comboBoxArrivalBerth.ItemsSource = availableBerths; this.comboBoxDepartureBerth.ItemsSource = availableBerths; - } - else - { - this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths; - this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths; - } + this.comboBoxMooring.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.MOORING); + this.comboBoxPilot.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.PILOT); + this.comboBoxTug.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.TUG); + this.comboBoxTerminal.ItemsSource = BreCalLists.GetParticipants(portId, ParticipantType.TERMINAL); + } this.CopyToControls(); - this.Title = this.ShipcallModel.Title; - Participant? p = null; - if (this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) - p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId); + + if (this.ShipcallModel != null) + { + this.Title = this.ShipcallModel.Title; + if (this.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) + p = BreCalLists.Participants.Find(x => x.Id == this.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId); + } bool allowBSMD = false; if (p != null)