diff --git a/SightKeeper.Avalonia/ViewModels/Dialogs/DataSet/DataSetEditingViewModel.cs b/SightKeeper.Avalonia/ViewModels/Dialogs/DataSet/DataSetEditingViewModel.cs index efcce272..f8fed1d3 100644 --- a/SightKeeper.Avalonia/ViewModels/Dialogs/DataSet/DataSetEditingViewModel.cs +++ b/SightKeeper.Avalonia/ViewModels/Dialogs/DataSet/DataSetEditingViewModel.cs @@ -32,10 +32,11 @@ public sealed partial class DataSetEditingViewModel : ValidatableDialogViewModel public Task> Games => _registeredGamesService.GetRegisteredGames(); public Domain.Model.DataSet DataSet { get; private set; } - public DataSetEditingViewModel(Domain.Model.DataSet dataSet, IValidator validator, RegisteredGamesService registeredGamesService, AssetsDataAccess assetsDataAccess) : base(validator) + public DataSetEditingViewModel(Domain.Model.DataSet dataSet, IValidator validator, RegisteredGamesService registeredGamesService, AssetsDataAccess assetsDataAccess, ItemClassDataAccess itemClassDataAccess) : base(validator) { _registeredGamesService = registeredGamesService; _assetsDataAccess = assetsDataAccess; + _itemClassDataAccess = itemClassDataAccess; SetData(dataSet); _disposable = ErrorsChangedObservable.Subscribe(_ => ApplyCommand.NotifyCanExecuteChanged()); } @@ -70,6 +71,7 @@ private void SetData(Domain.Model.DataSet dataSet) private readonly List _deletedItemClasses = new(); private readonly RegisteredGamesService _registeredGamesService; private readonly AssetsDataAccess _assetsDataAccess; + private readonly ItemClassDataAccess _itemClassDataAccess; ICommand IDataSetEditorViewModel.AddItemClassCommand => AddItemClassCommand; [RelayCommand(CanExecute = nameof(CanAddItemClass))] @@ -106,10 +108,11 @@ private bool CanAddItemClass() => [RelayCommand] private async Task DeleteItemClass(EditableItemClass itemClass) { - // HUGE mess! + // ISSUE HUGE mess! if (itemClass is ExistingItemClass existingItemClass) { DeletedItemClassAction? action = null; + await _itemClassDataAccess.LoadItems(existingItemClass.ItemClass); if (existingItemClass.ItemClass.Items.Any()) { const string deleteItems = "Delete items";