private void addTournamentButton_Click(object sender, RoutedEventArgs e) { var tournamentName = tournamentNameTextbox.Text; var selectedPlayers = playersListbox.SelectedItems; if (selectedPlayers.Count != 8) { MessageBox.Show($"You need to select 8 players to add them to the tournament"); return; } var succeded = _adminController.AddTournament(tournamentName); if (succeded) { MessageBox.Show($"Successfully added tournament \'{tournamentName}\'"); var getTournaments = new GetTournaments(); var tournament = getTournaments.GetByName(tournamentName); var createMatches = new CreateMatches(); var selectedUserList = new List <User>(); foreach (var selUser in selectedPlayers) { var newUser = new User(); newUser.Name = selUser.ToString(); selectedUserList.Add(newUser); } var succeededMatches = createMatches.Execute(tournament, selectedUserList); } else { MessageBox.Show($"Failed to add tournament \'{tournamentNameTextbox.Text}\'"); } }
public async Task <IActionResult> GetAllTournaments() { var getTournaments = new GetTournaments(); var tournaments = await _mediator.Send(getTournaments); return(Ok(tournaments)); }
public async Task <IEnumerable <TournamentInfoReadDto> > Handle(GetTournaments request, CancellationToken cancellationToken = default(CancellationToken)) { var tournaments = await _context .Tournaments .Fetch(FetchMode.ForRead) .ToListAsync(cancellationToken); return(_mapper.Map <IEnumerable <TournamentInfoReadDto> >(tournaments)); }
public UserWindow() { InitializeComponent(); var getTournaments = new GetTournaments(); var allTournaments = getTournaments.GetAll(); foreach (Tournament trn in allTournaments) { tounamentList.Items.Add(trn.Name); } }
private void tounamentList_SelectionChanged(object sender, SelectionChangedEventArgs e) { ClearScores(); var getTournaments = new GetTournaments(); var tournament = getTournaments.GetByName(tounamentList.SelectedItem.ToString()); currentTournament = tournament; labelPlayer11.Content = tournament.Matches[0].Player1.Name; labelPlayer12.Content = tournament.Matches[1].Player2.Name; labelPlayer13.Content = tournament.Matches[2].Player1.Name; labelPlayer14.Content = tournament.Matches[3].Player2.Name; labelPlayer15.Content = tournament.Matches[4].Player1.Name; labelPlayer16.Content = tournament.Matches[5].Player2.Name; labelPlayer17.Content = tournament.Matches[6].Player1.Name; labelPlayer18.Content = tournament.Matches[7].Player2.Name; if (tournament.Matches[0].Player1.Equals(Login.LoggedInUser) || tournament.Matches[1].Player1.Equals(Login.LoggedInUser)) { currentMatch = tournament.Matches[0]; match1P1.IsReadOnly = false; match1P2.IsReadOnly = false; } if (tournament.Matches[2].Player1.Equals(Login.LoggedInUser) || tournament.Matches[3].Player1.Equals(Login.LoggedInUser)) { currentMatch = tournament.Matches[2]; match2P1.IsReadOnly = false; match2P2.IsReadOnly = false; } if (tournament.Matches[4].Player1.Equals(Login.LoggedInUser) || tournament.Matches[5].Player1.Equals(Login.LoggedInUser)) { currentMatch = tournament.Matches[4]; match3P1.IsReadOnly = false; match3P2.IsReadOnly = false; } if (tournament.Matches[6].Player1.Equals(Login.LoggedInUser) || tournament.Matches[7].Player1.Equals(Login.LoggedInUser)) { currentMatch = tournament.Matches[6]; match4P1.IsReadOnly = false; match4P2.IsReadOnly = false; } }