Save and display a new shipcall
This commit is contained in:
parent
95fab27229
commit
ee5420ff5b
@ -31,6 +31,13 @@ namespace BreCalClient
|
|||||||
|
|
||||||
public List<Ship> Ships { get; set; } = new();
|
public List<Ship> Ships { get; set; } = new();
|
||||||
|
|
||||||
|
public Ship? SelectedShip {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.comboBoxShip.SelectedItem as Ship;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Event handler
|
#region Event handler
|
||||||
|
|||||||
@ -128,10 +128,9 @@ namespace BreCalClient
|
|||||||
|
|
||||||
if (esc.ShowDialog() ?? false)
|
if (esc.ShowDialog() ?? false)
|
||||||
{
|
{
|
||||||
// save new dialog model
|
// create UI & save new dialog model
|
||||||
|
this.UpdateShipcallUI(esc.Shipcall);
|
||||||
// add dialog model to list
|
this._api.ShipcallsPost(esc.Shipcall);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,6 +229,32 @@ namespace BreCalClient
|
|||||||
if (shipcalls != null)
|
if (shipcalls != null)
|
||||||
{
|
{
|
||||||
foreach (Shipcall shipcall in shipcalls)
|
foreach (Shipcall shipcall in shipcalls)
|
||||||
|
{
|
||||||
|
this.UpdateShipcallUI(shipcall);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ShipcallControl> removeList = new();
|
||||||
|
foreach (ShipcallControlModel scm in this._controlModels)
|
||||||
|
{
|
||||||
|
if (shipcalls.Find(s => s.Id == scm.Shipcall?.Id) == null) // the model is no longer in the search result
|
||||||
|
{
|
||||||
|
if((scm.Shipcall != null) && this._shipCallControlDict.ContainsKey(scm.Shipcall.Id))
|
||||||
|
{
|
||||||
|
this.Dispatcher.Invoke((Action)(() =>
|
||||||
|
{
|
||||||
|
this.stackPanel.Children.Remove(this._shipCallControlDict[scm.Shipcall.Id]);
|
||||||
|
}));
|
||||||
|
this._shipCallControlDict.Remove(scm.Shipcall.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(SHIPCALL_UPDATE_INTERVAL_SECONDS), _tokenSource.Token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateShipcallUI(Shipcall shipcall)
|
||||||
{
|
{
|
||||||
ShipcallControlModel? selectedSCMModel = null;
|
ShipcallControlModel? selectedSCMModel = null;
|
||||||
|
|
||||||
@ -278,28 +303,6 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
this._shipCallControlDict[shipcall.Id].RefreshData();
|
this._shipCallControlDict[shipcall.Id].RefreshData();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ShipcallControl> removeList = new();
|
|
||||||
foreach (ShipcallControlModel scm in this._controlModels)
|
|
||||||
{
|
|
||||||
if (shipcalls.Find(s => s.Id == scm.Shipcall?.Id) == null) // the model is no longer in the search result
|
|
||||||
{
|
|
||||||
if((scm.Shipcall != null) && this._shipCallControlDict.ContainsKey(scm.Shipcall.Id))
|
|
||||||
{
|
|
||||||
this.Dispatcher.Invoke((Action)(() =>
|
|
||||||
{
|
|
||||||
this.stackPanel.Children.Remove(this._shipCallControlDict[scm.Shipcall.Id]);
|
|
||||||
}));
|
|
||||||
this._shipCallControlDict.Remove(scm.Shipcall.Id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(SHIPCALL_UPDATE_INTERVAL_SECONDS), _tokenSource.Token);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Sc_EditRequested(ShipcallControl obj)
|
private async void Sc_EditRequested(ShipcallControl obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user