Avoid crash if delete is tried on deleted object
This commit is contained in:
parent
75585153d4
commit
bedf68c4d5
@ -47,7 +47,9 @@ namespace BreCalClient
|
|||||||
{
|
{
|
||||||
if (obj is ShipModel shipmodel)
|
if (obj is ShipModel shipmodel)
|
||||||
{
|
{
|
||||||
if(this.ShipApi != null)
|
if (!shipmodel.Ship.Deleted)
|
||||||
|
{
|
||||||
|
if (this.ShipApi != null)
|
||||||
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id);
|
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id);
|
||||||
BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships
|
BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships
|
||||||
shipmodel.Ship.Deleted = true; // set deleted marker on working instance
|
shipmodel.Ship.Deleted = true; // set deleted marker on working instance
|
||||||
@ -55,6 +57,7 @@ namespace BreCalClient
|
|||||||
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
|
this.dataGridShips.ItemsSource = BreCalLists.AllShips;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async void DataGridShips_EditRequested(object obj)
|
private async void DataGridShips_EditRequested(object obj)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user