clean up Navgationservices Navbar

This commit is contained in:
Natlinux
2023-02-05 20:40:46 +01:00
parent 7ac59d15b3
commit 4ef5f60ca0
6 changed files with 30 additions and 58 deletions

View File

@@ -1,5 +1,4 @@
using Apollon.Domain.Commands;
using Apollon.Domain.Models;
using Apollon.Domain.Queries;
using Apollon.EntityFramework;
using Apollon.EntityFramework.Commands;
@@ -8,19 +7,10 @@ using Apollon.WPF.Services;
using Apollon.WPF.Stores;
using Apollon.WPF.ViewModels;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Apollon.WPF
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private readonly NavigationStore _navigationStore;
@@ -67,17 +57,11 @@ namespace Apollon.WPF
_selectedTournamentStore,
_modalNavigationStore,
_tournamentStore,
_navigationStore,
CreateGroupsNavigationService());
_navigationStore.CurrentViewModel = OverviewViewModel.LoadViewModel(
_selectedTournamentStore,
_modalNavigationStore,
_tournamentStore,
_navigationStore,
CreateGroupsNavigationService());
CreateGroupsNavigationService(),
CreateNamelistNavigationService());
NavigationService<OverviewViewModel> overvoewNavigationService = CreateOverviewNavigationService();
overvoewNavigationService.Navigate();
MainWindow = new MainWindow()
{
@@ -91,13 +75,13 @@ namespace Apollon.WPF
private NavigationService<OverviewViewModel> CreateOverviewNavigationService()
{
return new NavigationService<OverviewViewModel>(
_navigationStore, () => OverviewViewModel.LoadViewModel(_selectedTournamentStore, _modalNavigationStore, _tournamentStore, _navigationStore, CreateGroupsNavigationService()));
_navigationStore, () => OverviewViewModel.LoadViewModel(_selectedTournamentStore, _modalNavigationStore, _tournamentStore, CreateGroupsNavigationService(), CreateNamelistNavigationService()));
}
private NavigationService<GroupsViewModel> CreateGroupsNavigationService()
{
return new NavigationService<GroupsViewModel>(
_navigationStore, () => new GroupsViewModel( _navBarPreparationViewModel, _selectedTournamentStore, _navigationStore, _modalNavigationStore, _tournamentStore, CreateGroupsNavigationService()));
_navigationStore, () => new GroupsViewModel(_navBarPreparationViewModel, _selectedTournamentStore, CreateOverviewNavigationService()));
}
private NavigationService<ClassesViewModel> CreateClassesNavigationService()

View File

@@ -2,9 +2,6 @@
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.Commands
@@ -12,19 +9,15 @@ namespace Apollon.WPF.Commands
public class AddTournamentCommand : AsyncCommandBase
{
private readonly TournamentsStore _tournamentStore;
private readonly NavigationStore _navigationStore;
private readonly ModalNavigationStore _modalNavigationStore;
private readonly SelectedTournamentsStore _selectedTournamentsStore;
private AddTournamentViewModel _addTournamentViewModel;
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, SelectedTournamentsStore selectedTournamentsStore)
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
{
_addTournamentViewModel = addTournamentViewModel;
_tournamentStore = tournamentStore;
_modalNavigationStore = modalNavigationStore;
_navigationStore = navigationStore;
_selectedTournamentsStore = selectedTournamentsStore;
}
public override async Task ExecuteAsync(object parameter)
@@ -52,7 +45,6 @@ namespace Apollon.WPF.Commands
await _tournamentStore.Add(tournament);
_modalNavigationStore.Close();
//_navigationStore.CurrentViewModel = new GroupsViewModel(_selectedTournamentsStore, _navigationStore, _modalNavigationStore, _tournamentStore);
}
catch (Exception)

View File

@@ -11,21 +11,18 @@ namespace Apollon.WPF.Commands
public class OpenAddTournamentCommand : CommandBase
{
private readonly TournamentsStore _tournamentStore;
private readonly SelectedTournamentsStore _selectedTournamentsStore;
private readonly NavigationStore _navigationStore;
private readonly ModalNavigationStore _modalNavigationStore;
public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, SelectedTournamentsStore selectedTournamentsStore)
public OpenAddTournamentCommand(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
{
_tournamentStore = tournamentStore;
_navigationStore = navigationStore;
_modalNavigationStore = modalNavigationStore;
_selectedTournamentsStore = selectedTournamentsStore;
}
public override void Execute(object parameter)
{
AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore, _navigationStore, _selectedTournamentsStore);
AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore);
_modalNavigationStore.CurrentViewModel = addTournamentViewModel;
}
}

View File

@@ -13,9 +13,9 @@ namespace Apollon.WPF.ViewModels
{
public AddEditDetailsViewModel AddEditDetailsViewModel { get; }
public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore, NavigationStore navigationStore,SelectedTournamentsStore selectedTournamentsStore)
public AddTournamentViewModel(TournamentsStore tournamentStore, ModalNavigationStore modalNavigationStore)
{
ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore,navigationStore, selectedTournamentsStore);
ICommand submitCommand = new AddTournamentCommand(this, tournamentStore,modalNavigationStore);
ICommand cancelCommand = new CloseModalCommand(modalNavigationStore);
AddEditDetailsViewModel = new AddEditDetailsViewModel(submitCommand, cancelCommand);
}

View File

@@ -18,13 +18,13 @@ namespace Apollon.WPF.ViewModels
public NavBarPreparationViewModel NavBarPreparationViewModel { get; }
public ICommand NavigateOverviewCommand { get; }
public GroupsViewModel(NavBarPreparationViewModel navBarPreparationViewModel, SelectedTournamentsStore selectedTournamentStore, NavigationStore navigationStore, ModalNavigationStore modalNavigationStore, TournamentsStore tournamentsStore, NavigationService<GroupsViewModel> groupNavigationService)
public GroupsViewModel(NavBarPreparationViewModel navBarPreparationViewModel, SelectedTournamentsStore selectedTournamentStore, NavigationService<OverviewViewModel> overviewNavigationService)
{
TournamentDetailsViewModel = new TournamentDetailsViewModel(selectedTournamentStore);
NavBarPreparationViewModel = navBarPreparationViewModel;
NavigateOverviewCommand = new NavigateCommand<OverviewViewModel>(new NavigationService<OverviewViewModel>(navigationStore, () => OverviewViewModel.LoadViewModel(selectedTournamentStore, modalNavigationStore, tournamentsStore, navigationStore, groupNavigationService)));
NavigateOverviewCommand = new NavigateCommand<OverviewViewModel>(overviewNavigationService);
}
}
}

View File

@@ -46,25 +46,24 @@ namespace Apollon.WPF.ViewModels
public ICommand NavigateNameListCommand { get; }
public OverviewViewModel(TournamentsStore tournamentStore, SelectedTournamentsStore selectedTournamentStore,
ModalNavigationStore modalNavigationStore, NavigationStore navigationStore, NavigationService<GroupsViewModel> groupNavigationService)
ModalNavigationStore modalNavigationStore, NavigationService<GroupsViewModel> groupNavigationService, NavigationService<NameListViewModel> NameListNavigationService)
{
OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore);
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore ,groupNavigationService);
LoadTournamentsCommand = new LoadTournamentsCommand(this, tournamentStore);
OpenAddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore, navigationStore, selectedTournamentStore);
NavigateNameListCommand = new NavigateCommand<NameListViewModel>(new NavigationService<NameListViewModel>(
navigationStore, () => new NameListViewModel()));
OpenAddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore);
NavigateNameListCommand = new NavigateCommand<NameListViewModel>(NameListNavigationService);
}
public static OverviewViewModel LoadViewModel(SelectedTournamentsStore selectedTournamentStore,
ModalNavigationStore modalNavigationStore,
TournamentsStore tournamentStore,
NavigationStore navigationStore,
NavigationService<GroupsViewModel> groupNavigationService)
NavigationService<GroupsViewModel> groupNavigationService,
NavigationService<NameListViewModel> NameListNavigationService)
{
OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore, navigationStore, groupNavigationService);
OverviewViewModel viewModel = new OverviewViewModel(tournamentStore, selectedTournamentStore, modalNavigationStore,groupNavigationService, NameListNavigationService);
viewModel.LoadTournamentsCommand.Execute(null);