Avoid crash if delete is tried on deleted object
This commit is contained in:
parent
8b2b454f97
commit
56d9346f9d
@ -47,12 +47,15 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
if (obj is ShipModel shipmodel)
|
if (obj is ShipModel shipmodel)
|
||||||
{
|
{
|
||||||
if(this.ShipApi != null)
|
if (!shipmodel.Ship.Deleted)
|
||||||
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id);
|
{
|
||||||
BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships
|
if (this.ShipApi != null)
|
||||||
shipmodel.Ship.Deleted = true; // set deleted marker on working instance
|
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id);
|
||||||
this.dataGridShips.ItemsSource = null;
|
BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships
|
||||||
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
|
shipmodel.Ship.Deleted = true; // set deleted marker on working instance
|
||||||
|
this.dataGridShips.ItemsSource = null;
|
||||||
|
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user