using Apollon.WPF.Commands; using Apollon.WPF.Models; using Apollon.WPF.Stores; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; namespace Apollon.WPF.ViewModels { public class OverviewListingViewModel : ViewModelBase { private readonly ObservableCollection _overviewListingItemViewModels; private readonly SelectedTournamentStore _selectedTournamentStore; private readonly ModalNavigationStore _modalNavigationStore; private readonly TournamentStore _tournamentStore; public IEnumerable OverviewListingItemViewModels => _overviewListingItemViewModels; private OverviewListingItemViewModel _selectedOverviewListingItemViewModel; public OverviewListingItemViewModel SelectedOverviewListingItemViewModel { get { return _selectedOverviewListingItemViewModel; } set { _selectedOverviewListingItemViewModel = value; OnPropertyChanged(nameof(SelectedOverviewListingItemViewModel)); _selectedTournamentStore.SelectedTournament = _selectedOverviewListingItemViewModel.Tournament; } } public OverviewListingViewModel(SelectedTournamentStore selectedTournamentStore, ModalNavigationStore modalNavigationStore, TournamentStore tournamentStore) { _tournamentStore = tournamentStore; _selectedTournamentStore = selectedTournamentStore; _modalNavigationStore = modalNavigationStore; _overviewListingItemViewModels = new ObservableCollection(); _tournamentStore.TournamentAdded += TournamentStore_TournamentAdded; } protected override void Dispose() { _tournamentStore.TournamentAdded -= TournamentStore_TournamentAdded; base.Dispose(); } private void TournamentStore_TournamentAdded(Tournament tournament) { AddTournament(tournament); } private void AddTournament(Tournament tournament) { // TO DO EditTournamentCommand _overviewListingItemViewModels.Add(new OverviewListingItemViewModel(tournament)); } } }