Add a Tournament
This commit is contained in:
@@ -32,22 +32,26 @@ namespace Apollon.WPF.Commands
|
|||||||
public override async Task ExecuteAsync(object parameter)
|
public override async Task ExecuteAsync(object parameter)
|
||||||
{
|
{
|
||||||
AddEditDetailsViewModel formViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
AddEditDetailsViewModel formViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
||||||
Tournament tournament = new Tournament(formViewModel.Organisation,formViewModel.TournamentName, formViewModel.Competition, formViewModel.StartDate, formViewModel.EndDate,
|
Tournament tournament = new Tournament(
|
||||||
formViewModel.Location, formViewModel.Rounds);
|
formViewModel.Organisation,
|
||||||
|
formViewModel.TournamentName,
|
||||||
|
formViewModel.Competition,
|
||||||
|
formViewModel.StartDate,
|
||||||
|
formViewModel.EndDate,
|
||||||
|
formViewModel.Location,
|
||||||
|
formViewModel.Rounds);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _tournamentStore.Add(tournament);
|
await _tournamentStore.Add(tournament);
|
||||||
|
|
||||||
|
_modalNavigationStore.Close();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
// Add Tournament to Database
|
|
||||||
|
|
||||||
|
|
||||||
_modalNavigationStore.Close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,16 +45,21 @@ namespace Apollon.WPF.ViewModels
|
|||||||
_modalNavigationStore = modalNavigationStore;
|
_modalNavigationStore = modalNavigationStore;
|
||||||
_overviewListingItemViewModels = new ObservableCollection<OverviewListingItemViewModel>();
|
_overviewListingItemViewModels = new ObservableCollection<OverviewListingItemViewModel>();
|
||||||
|
|
||||||
//_overviewListingItemViewModels.Add(new OverviewListingItemViewModel(new Tournament("DSB", "Meisterschaft", "Halle", DateTime.Now, DateTime.Now, "Bruchsal", 10)));
|
_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", DateTime.Now, DateTime.Today, "Bruchsal", 6), modalNavigationStore);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddTournament(Tournament tournament, ModalNavigationStore modalNavigationStore)
|
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
|
// TO DO EditTournamentCommand
|
||||||
_overviewListingItemViewModels.Add(new OverviewListingItemViewModel(tournament));
|
_overviewListingItemViewModels.Add(new OverviewListingItemViewModel(tournament));
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace Apollon.WPF.ViewModels
|
|||||||
public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
|
public OverviewDetailsViewModel OverviewDetailsViewModel{ get; }
|
||||||
|
|
||||||
public ICommand AddTournamentCommand { get; }
|
public ICommand AddTournamentCommand { get; }
|
||||||
public ICommand EditTournamentCommand { get; set ; }
|
public ICommand EditTournamentCommand { get;}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -28,12 +28,6 @@ namespace Apollon.WPF.ViewModels
|
|||||||
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore);
|
AddTournamentCommand = new OpenAddTournamentCommand(tournamentStore, modalNavigationStore);
|
||||||
EditTournamentCommand = new OpenEditTournamentCommand(modalNavigationStore);
|
EditTournamentCommand = new OpenEditTournamentCommand(modalNavigationStore);
|
||||||
|
|
||||||
AddTournament(new Tournament("DSB", "Deutschemeisterschaft3", "Halle", DateTime.Now, DateTime.Today, "Bruchsal", 6), modalNavigationStore);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AddTournament(Tournament tournament, ModalNavigationStore modalNavigationStore)
|
|
||||||
{
|
|
||||||
ICommand editTournamentCommand = new EditTournamentCommand(modalNavigationStore);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user