AddTournament To list by add

This commit is contained in:
Natlinux81
2022-08-16 03:52:02 +02:00
parent cc060b273a
commit 4531f31658
7 changed files with 90 additions and 18 deletions

View File

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

View File

@@ -15,6 +15,9 @@ namespace Apollon.WPF.ViewModels
{
private readonly ObservableCollection<OverviewListingItemViewModel> _overviewListingItemViewModels;
private readonly SelectedTournamentStore _selectedTournamentStore;
private readonly ModalNavigationStore _modalNavigationStore;
private readonly TournamentStore _tournamentStore;
public IEnumerable<OverviewListingItemViewModel> OverviewListingItemViewModels => _overviewListingItemViewModels;
@@ -35,20 +38,36 @@ namespace Apollon.WPF.ViewModels
}
}
public OverviewListingViewModel(SelectedTournamentStore selectedTournamentStore, ModalNavigationStore modalNavigationStore)
public OverviewListingViewModel(SelectedTournamentStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, TournamentStore tournamentStore)
{
_tournamentStore = tournamentStore;
_selectedTournamentStore = selectedTournamentStore;
_modalNavigationStore = modalNavigationStore;
_overviewListingItemViewModels = new ObservableCollection<OverviewListingItemViewModel>();
AddTournament(new Tournament("DSB", "Deutschemeisterschaft1", "Halle", "01.01.2021", "05.01.2021", "Wiesbaden",3),modalNavigationStore);
AddTournament(new Tournament("DSB", "Deutschemeisterschaft2", "im Freien", "01.01.2021", "05.01.2021", "Berlin",5),modalNavigationStore);
AddTournament(new Tournament("DSB", "Deutschemeisterschaft3", "Halle", "01.01.2021", "05.01.2021", "Bruchsal", 6),modalNavigationStore);
_tournamentStore.TournamentAdded += _tournamentStore_TournamentAdded;
//AddTournament(new Tournament("DSB", "Deutschemeisterschaft1", "Halle", "01.01.2021", "05.01.2021", "Wiesbaden",3),modalNavigationStore);
//AddTournament(new Tournament("DSB", "Deutschemeisterschaft2", "im Freien", "01.01.2021", "05.01.2021", "Berlin",5),modalNavigationStore);
//AddTournament(new Tournament("DSB", "Deutschemeisterschaft3", "Halle", "01.01.2021", "05.01.2021", "Bruchsal", 6),modalNavigationStore);
}
private void AddTournament(Tournament tournament, ModalNavigationStore modalNavigationStore)
protected override void Dispose()
{
ICommand editTournamentCommand = new OpenAddTournamentCommand(modalNavigationStore);
_tournamentStore.TournamentAdded -= _tournamentStore_TournamentAdded;
base.Dispose();
}
private void _tournamentStore_TournamentAdded(Tournament tournament)
{
AddTournament(tournament);
}
private void AddTournament(Tournament tournament)
{
//ICommand editTournamentCommand = new OpenEditTournamentCommand(_modalNavigationStore);
_overviewListingItemViewModels.Add(new OverviewListingItemViewModel(tournament
//,editTournamentCommand
));

View File

@@ -20,12 +20,12 @@ namespace Apollon.WPF.ViewModels
public OverviewViewModel(SelectedTournamentStore selectedTournamentStore, ModalNavigationStore modalNavigationStore)
public OverviewViewModel(TournamentStore tournamentStore, SelectedTournamentStore selectedTournamentStore, ModalNavigationStore modalNavigationStore)
{
OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore);
OverviewListingViewModel = new OverviewListingViewModel(selectedTournamentStore, modalNavigationStore, tournamentStore);
OverviewDetailsViewModel = new OverviewDetailsViewModel(selectedTournamentStore);
AddTournamentCommand = new OpenAddTournamentCommand(modalNavigationStore);
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore);
//EditTournamentCommand = new OpenEditTournamentCommand(modalNavigationStore);
}
}