Avoid crash if delete is tried on deleted object

This commit is contained in:
Daniel Schick 2024-04-18 15:36:15 +02:00
parent 8b2b454f97
commit 56d9346f9d

View File

@ -47,7 +47,9 @@ namespace BreCalClient
{
if (obj is ShipModel shipmodel)
{
if(this.ShipApi != null)
if (!shipmodel.Ship.Deleted)
{
if (this.ShipApi != null)
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id);
BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships
shipmodel.Ship.Deleted = true; // set deleted marker on working instance
@ -55,6 +57,7 @@ namespace BreCalClient
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
}
}
}
private async void DataGridShips_EditRequested(object obj)
{