Revert "impliment NavigateService"

This reverts commit 439850b5b7.
This commit is contained in:
Natlinux
2022-11-27 13:18:15 +01:00
parent 439850b5b7
commit a2c926f915
7 changed files with 19 additions and 57 deletions

View File

@@ -1,5 +1,4 @@
using Apollon.Domain.Models;
using Apollon.WPF.Services;
using Apollon.WPF.Stores;
using Apollon.WPF.ViewModels;
using System;
@@ -13,23 +12,19 @@ namespace Apollon.WPF.Commands
public class AddTournamentCommand : AsyncCommandBase
{
private readonly TournamentsStore _tournamentStore;
private readonly NavigationService<PreparationViewModel> _navigationService;
private readonly NavigationStore _navigationStore;
private readonly ModalNavigationStore _modalNavigationStore;
private readonly SelectedTournamentsStore _selectedTournamentsStore;
private AddTournamentViewModel _addTournamentViewModel;
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, NavigationService<PreparationViewModel> navigationService)
{
}
public AddTournamentCommand(TournamentsStore tournamentStore, NavigationService<PreparationViewModel> navigationService, ModalNavigationStore modalNavigationStore,
SelectedTournamentsStore selectedTournamentsStore, AddTournamentViewModel addTournamentViewModel)
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, SelectedTournamentsStore selectedTournamentsStore)
{
_tournamentStore = tournamentStore;
_navigationService = navigationService;
_modalNavigationStore = modalNavigationStore;
_selectedTournamentsStore = selectedTournamentsStore;
_addTournamentViewModel = addTournamentViewModel;
_tournamentStore = tournamentStore;
_modalNavigationStore = modalNavigationStore;
_navigationStore = navigationStore;
_selectedTournamentsStore = selectedTournamentsStore;
}
public override async Task ExecuteAsync(object parameter)
@@ -57,7 +52,7 @@ namespace Apollon.WPF.Commands
await _tournamentStore.Add(tournament);
_modalNavigationStore.Close();
_navigationService.Navigate();
_navigationStore.CurrentViewModel = new PreparationViewModel(_selectedTournamentsStore, _navigationStore, _modalNavigationStore, _tournamentStore);
}
catch (Exception)

View File

@@ -1,5 +1,4 @@
using Apollon.WPF.Services;
using Apollon.WPF.Stores;
using Apollon.WPF.Stores;
using Apollon.WPF.ViewModels;
using System;
using System.Collections.Generic;
@@ -12,16 +11,18 @@ namespace Apollon.WPF.Commands
public class NavigateCommand<TViewModel> : CommandBase
where TViewModel : ViewModelBase
{
private readonly NavigationService<TViewModel> _navigationService;
private readonly NavigationStore _navigationStore;
private readonly Func<TViewModel> _createViewModel;
public NavigateCommand(NavigationService<TViewModel> navigationService)
public NavigateCommand(NavigationStore navigationStore, Func<TViewModel> createViewModel)
{
_navigationService = navigationService;
_navigationStore = navigationStore;
_createViewModel = createViewModel;
}
public override void Execute(object parameter)
{
_navigationService.Navigate();
_navigationStore.CurrentViewModel = _createViewModel();
}
}
}

View File

@@ -1,28 +0,0 @@
using Apollon.WPF.Stores;
using Apollon.WPF.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apollon.WPF.Services
{
public class NavigationService<TViewModel>
where TViewModel : ViewModelBase
{
private readonly NavigationStore _navigationStore;
private readonly Func<TViewModel> _createViewModel;
public NavigationService(NavigationStore navigationStore, Func<TViewModel> createViewModel)
{
_navigationStore = navigationStore;
_createViewModel = createViewModel;
}
public void Navigate()
{
_navigationStore.CurrentViewModel = _createViewModel();
}
}
}

View File

@@ -1,5 +1,4 @@
using Apollon.WPF.Commands;
using Apollon.WPF.Services;
using Apollon.WPF.Stores;
using System;
using System.Collections.Generic;
@@ -16,7 +15,7 @@ namespace Apollon.WPF.ViewModels
public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore,SelectedTournamentsStore selectedTournamentsStore)
{
ICommand submitCommand = new AddTournamentCommand(this, new NavigationService<PreparationViewModel>(navigationStore, () => new PreparationViewModel( selectedTournamentsStore, navigationStore, modalNavigationStore, tournamentStore)));
ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore,navigationStore, selectedTournamentsStore);
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand);
}

View File

@@ -1,6 +1,5 @@
using Apollon.Domain.Models;
using Apollon.WPF.Commands;
using Apollon.WPF.Services;
using Apollon.WPF.Stores;
using System;
using System.Collections.Generic;
@@ -36,8 +35,7 @@ namespace Apollon.WPF.ViewModels
_selectedTournamentStore.SelectedTournamentChanged += SelectedTournamentStore_SelectedTournamentChanged;
NavigateTournamentDetailsCommand = new NavigateCommand<PreparationViewModel>(new NavigationService<PreparationViewModel>(navigationStore,() => new PreparationViewModel(
selectedTournamentStore,navigationStore,modalNavigationStore, tournamentsStore)));
NavigateTournamentDetailsCommand = new NavigateCommand<PreparationViewModel>(navigationStore, () => new PreparationViewModel(_selectedTournamentStore,navigationStore, modalNavigationStore, tournamentsStore));
}
protected override void Dispose()

View File

@@ -7,7 +7,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Apollon.WPF.Services;
namespace Apollon.WPF.ViewModels
{
@@ -59,7 +58,7 @@ namespace Apollon.WPF.ViewModels
LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore);
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, navigationStore, selectedTournamentStore);
NavigateNameListCommand = new NavigateCommand<NameListViewModel>(new NavigationService<NameListViewModel>(navigationStore, () => new NameListViewModel()));
NavigateNameListCommand = new NavigateCommand<NameListViewModel>(navigationStore, () => new NameListViewModel());
}

View File

@@ -1,6 +1,5 @@
using Apollon.Domain.Models;
using Apollon.WPF.Commands;
using Apollon.WPF.Services;
using Apollon.WPF.Stores;
using System;
using System.Collections.Generic;
@@ -22,8 +21,7 @@ namespace Apollon.WPF.ViewModels
{
TournamentDetailsViewModel = new TournamentDetailsViewModel(selectedTournamentStore);
NavigateOverviewCommand = new NavigateCommand<OverviewViewModel>(new NavigationService<OverviewViewModel>(navigationStore, () => OverviewViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentsStore, navigationStore)));
NavigateOverviewCommand = new NavigateCommand<OverviewViewModel>(navigationStore, () => OverviewViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentsStore, navigationStore));
}
}