private void DeleteItemCommandExecute() { try { if (WarehouseItem != null) { MessageBoxResult result = MessageBox.Show("Are you sure you want to delete warehouse item?", "Delete Record", MessageBoxButton.OKCancel); switch (result) { case MessageBoxResult.OK: int itemId = warehouseItem.ID; dataBaseService.DeleteWarehouseItem(itemId); string logMessage = string.Format("Warehouse Item: {0}, Item number: {1}, Item amount: {2}, was deleted from database.", WarehouseItem.ProductName, WarehouseItem.ProductNumber, WarehouseItem.Amount); actionEventObject.OnActionPerformed(logMessage); WarehouseItemList = dataBaseService.GetAllWarehouseItems().ToList(); MessageBox.Show("Item deleted!", "Delete Record"); break; case MessageBoxResult.Cancel: break; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }