AddTournament To list by add
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Apollon.WPF.Stores;
|
||||
using Apollon.WPF.Models;
|
||||
using Apollon.WPF.Stores;
|
||||
using Apollon.WPF.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -9,16 +11,41 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class AddTournamentCommand : AsyncCommandBase
|
||||
{
|
||||
private readonly TournamentStore _tournamentStore;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
private AddTournamentViewModel _addTournamentViewModel;
|
||||
|
||||
|
||||
public AddTournamentCommand(ModalNavigationStore modalNavigationStore)
|
||||
public AddTournamentCommand(TournamentStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_tournamentStore = tournamentStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
}
|
||||
}
|
||||
|
||||
public AddTournamentCommand(AddTournamentViewModel addTournamentViewModel, TournamentStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_addTournamentViewModel = addTournamentViewModel;
|
||||
_tournamentStore = tournamentStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(object parameter)
|
||||
{
|
||||
AddEditDetailsViewModel formViewModel = _addTournamentViewModel.AddEditDetailsViewModel;
|
||||
Tournament tournament = new Tournament(formViewModel.Organisation,formViewModel.Tournamentname, formViewModel.Category, formViewModel.Startdate, formViewModel.Enddate,
|
||||
formViewModel.Location, formViewModel.Rounds);
|
||||
|
||||
try
|
||||
{
|
||||
await _tournamentStore.Add(tournament);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
// Add Tournament to Database
|
||||
|
||||
|
||||
_modalNavigationStore.Close();
|
||||
}
|
||||
|
||||
@@ -10,16 +10,18 @@ namespace Apollon.WPF.Commands
|
||||
{
|
||||
public class OpenAddTournamentCommand : CommandBase
|
||||
{
|
||||
private readonly TournamentStore _tournamentStore;
|
||||
private readonly ModalNavigationStore _modalNavigationStore;
|
||||
|
||||
public OpenAddTournamentCommand(ModalNavigationStore modalNavigationStore)
|
||||
public OpenAddTournamentCommand(TournamentStore tournamentStore, ModalNavigationStore modalNavigationStore)
|
||||
{
|
||||
_tournamentStore = tournamentStore;
|
||||
_modalNavigationStore = modalNavigationStore;
|
||||
}
|
||||
|
||||
public override void Execute(object parameter)
|
||||
{
|
||||
AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_modalNavigationStore);
|
||||
AddTournamentViewModel addTournamentViewModel = new AddTournamentViewModel(_tournamentStore, _modalNavigationStore);
|
||||
_modalNavigationStore.CurrentViewModel = addTournamentViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user