Don't crash on ship delete API error

This commit is contained in:
Daniel Schick 2024-09-09 13:11:56 +02:00
parent 8028382e79
commit 93362d3695

View File

@ -48,9 +48,16 @@ namespace BreCalClient
if (obj is ShipModel shipmodel) if (obj is ShipModel shipmodel)
{ {
if (!shipmodel.Ship.Deleted) if (!shipmodel.Ship.Deleted)
{
try
{ {
if (this.ShipApi != null) if (this.ShipApi != null)
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id); await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
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
this.dataGridShips.ItemsSource = null; this.dataGridShips.ItemsSource = null;