ButtonRemoveBoat_Click logging

This commit is contained in:
Nikita Potapov 2022-11-26 23:13:28 +04:00
parent 8659337eb5
commit 57dab5fc82

View File

@ -129,13 +129,16 @@ namespace Boats
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
try
{
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
var deletedBoat = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos;
if (deletedBoat != null)
{
MessageBox.Show("Объект удален");
_logger.LogInformation($"Удален объект {deletedBoat.GetType().Name}");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
_logger.LogInformation($"Не удалось удалить объект по позиции {pos}: объект равен null");
MessageBox.Show("Не удалось удалить объект");
}
}