Skip to content

Commit

Permalink
Load ItemClasses items before checking them when preparing to deleting;
Browse files Browse the repository at this point in the history
  • Loading branch information
Neakita committed Sep 12, 2023
1 parent 99d362e commit 70ce9ad
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ public sealed partial class DataSetEditingViewModel : ValidatableDialogViewModel
public Task<IReadOnlyCollection<Game>> Games => _registeredGamesService.GetRegisteredGames();
public Domain.Model.DataSet DataSet { get; private set; }

public DataSetEditingViewModel(Domain.Model.DataSet dataSet, IValidator<DataSetChanges> validator, RegisteredGamesService registeredGamesService, AssetsDataAccess assetsDataAccess) : base(validator)
public DataSetEditingViewModel(Domain.Model.DataSet dataSet, IValidator<DataSetChanges> validator, RegisteredGamesService registeredGamesService, AssetsDataAccess assetsDataAccess, ItemClassDataAccess itemClassDataAccess) : base(validator)
{
_registeredGamesService = registeredGamesService;
_assetsDataAccess = assetsDataAccess;
_itemClassDataAccess = itemClassDataAccess;
SetData(dataSet);
_disposable = ErrorsChangedObservable.Subscribe(_ => ApplyCommand.NotifyCanExecuteChanged());
}
Expand Down Expand Up @@ -70,6 +71,7 @@ private void SetData(Domain.Model.DataSet dataSet)
private readonly List<DeletedItemClass> _deletedItemClasses = new();
private readonly RegisteredGamesService _registeredGamesService;
private readonly AssetsDataAccess _assetsDataAccess;
private readonly ItemClassDataAccess _itemClassDataAccess;

ICommand IDataSetEditorViewModel.AddItemClassCommand => AddItemClassCommand;
[RelayCommand(CanExecute = nameof(CanAddItemClass))]
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 70ce9ad

Please sign in to comment.