From a2c926f91596cfcfa1631f20dabc4f4c2d4cdd00 Mon Sep 17 00:00:00 2001 From: Natlinux <97396587+Natlinux81@users.noreply.github.com> Date: Sun, 27 Nov 2022 13:18:15 +0100 Subject: [PATCH] Revert "impliment NavigateService" This reverts commit 439850b5b7bde417030f90f2e028bf3cb8e3ea90. --- Apollon.WPF/Commands/AddTournamentCommand.cs | 19 +++++-------- Apollon.WPF/Commands/NavigateCommand.cs | 15 +++++----- Apollon.WPF/Services/NavigationService.cs | 28 ------------------- .../ViewModels/AddTournametViewModel.cs | 3 +- .../ViewModels/OverviewDetailsViewModel.cs | 4 +-- Apollon.WPF/ViewModels/OverviewViewModel.cs | 3 +- .../ViewModels/PreparationViewModel.cs | 4 +-- 7 files changed, 19 insertions(+), 57 deletions(-) delete mode 100644 Apollon.WPF/Services/NavigationService.cs diff --git a/Apollon.WPF/Commands/AddTournamentCommand.cs b/Apollon.WPF/Commands/AddTournamentCommand.cs index 3790b5c..c9b1b56 100644 --- a/Apollon.WPF/Commands/AddTournamentCommand.cs +++ b/Apollon.WPF/Commands/AddTournamentCommand.cs @@ -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 _navigationService; + private readonly NavigationStore _navigationStore; private readonly ModalNavigationStore _modalNavigationStore; private readonly SelectedTournamentsStore _selectedTournamentsStore; private AddTournamentViewModel _addTournamentViewModel; - public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, NavigationService navigationService) - { - } - public AddTournamentCommand(TournamentsStore tournamentStore, NavigationService 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) diff --git a/Apollon.WPF/Commands/NavigateCommand.cs b/Apollon.WPF/Commands/NavigateCommand.cs index 6a20234..30dc6ec 100644 --- a/Apollon.WPF/Commands/NavigateCommand.cs +++ b/Apollon.WPF/Commands/NavigateCommand.cs @@ -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 : CommandBase where TViewModel : ViewModelBase { - private readonly NavigationService _navigationService; + private readonly NavigationStore _navigationStore; + private readonly Func _createViewModel; - public NavigateCommand(NavigationService navigationService) + public NavigateCommand(NavigationStore navigationStore, Func createViewModel) { - _navigationService = navigationService; + _navigationStore = navigationStore; + _createViewModel = createViewModel; } public override void Execute(object parameter) - { - _navigationService.Navigate(); + { + _navigationStore.CurrentViewModel = _createViewModel(); } } } diff --git a/Apollon.WPF/Services/NavigationService.cs b/Apollon.WPF/Services/NavigationService.cs deleted file mode 100644 index 8154cbd..0000000 --- a/Apollon.WPF/Services/NavigationService.cs +++ /dev/null @@ -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 - where TViewModel : ViewModelBase - { - private readonly NavigationStore _navigationStore; - private readonly Func _createViewModel; - - public NavigationService(NavigationStore navigationStore, Func createViewModel) - { - _navigationStore = navigationStore; - _createViewModel = createViewModel; - } - - public void Navigate() - { - _navigationStore.CurrentViewModel = _createViewModel(); - } - } -} diff --git a/Apollon.WPF/ViewModels/AddTournametViewModel.cs b/Apollon.WPF/ViewModels/AddTournametViewModel.cs index 7b79432..1020230 100644 --- a/Apollon.WPF/ViewModels/AddTournametViewModel.cs +++ b/Apollon.WPF/ViewModels/AddTournametViewModel.cs @@ -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(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); } diff --git a/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs b/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs index 603a2dd..9e94e47 100644 --- a/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewDetailsViewModel.cs @@ -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(new NavigationService(navigationStore,() => new PreparationViewModel( - selectedTournamentStore,navigationStore,modalNavigationStore, tournamentsStore))); + NavigateTournamentDetailsCommand = new NavigateCommand(navigationStore, () => new PreparationViewModel(_selectedTournamentStore,navigationStore, modalNavigationStore, tournamentsStore)); } protected override void Dispose() diff --git a/Apollon.WPF/ViewModels/OverviewViewModel.cs b/Apollon.WPF/ViewModels/OverviewViewModel.cs index 3a2d278..7374a5e 100644 --- a/Apollon.WPF/ViewModels/OverviewViewModel.cs +++ b/Apollon.WPF/ViewModels/OverviewViewModel.cs @@ -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(new NavigationService(navigationStore, () => new NameListViewModel())); + NavigateNameListCommand = new NavigateCommand(navigationStore, () => new NameListViewModel()); } diff --git a/Apollon.WPF/ViewModels/PreparationViewModel.cs b/Apollon.WPF/ViewModels/PreparationViewModel.cs index d01831c..5a9ac41 100644 --- a/Apollon.WPF/ViewModels/PreparationViewModel.cs +++ b/Apollon.WPF/ViewModels/PreparationViewModel.cs @@ -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(new NavigationService(navigationStore, () => OverviewViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentsStore, navigationStore))); - + NavigateOverviewCommand = new NavigateCommand(navigationStore, () => OverviewViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentsStore, navigationStore)); } }