From 70a4f3cd42325ebe5490a566834766a8026d4a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Tue, 19 May 2020 08:02:30 +0200 Subject: [PATCH] Ready built Tournament Tracker --- .../ViewModels/TournamentViewerViewModel.cs | 57 ++++++++++++++++--- TrackerWPFUI/Views/ShellView.xaml | 6 +- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/TrackerWPFUI/ViewModels/TournamentViewerViewModel.cs b/TrackerWPFUI/ViewModels/TournamentViewerViewModel.cs index 5e13848..514a1e9 100644 --- a/TrackerWPFUI/ViewModels/TournamentViewerViewModel.cs +++ b/TrackerWPFUI/ViewModels/TournamentViewerViewModel.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using TrackerLibrary; using TrackerLibrary.Models; namespace TrackerWPFUI.ViewModels @@ -12,6 +13,7 @@ namespace TrackerWPFUI.ViewModels { public TournamentModel Tournament { get; set; } + private string _tournamentName; private BindableCollection _rounds = new BindableCollection(); private BindableCollection _matchups = new BindableCollection(); private bool _unplayedOnly; @@ -22,16 +24,24 @@ namespace TrackerWPFUI.ViewModels private MatchupModel _selectedMatchup; private int _selectedRound = 0; - - - - public TournamentViewerViewModel(TournamentModel model) { Tournament = model; + TournamentName = model.TournamentName; LoadRounds(); } + public string TournamentName + { + get { + return $"Tournament: {_tournamentName}" ; + } + set { _tournamentName = value; + NotifyOfPropertyChange(() => TournamentName); + } + } + + public int SelectedRound { get { return _selectedRound; } @@ -103,15 +113,12 @@ namespace TrackerWPFUI.ViewModels set { _matchups = value; } } - public BindableCollection Rounds { get { return _rounds; } set { _rounds = value; } } - - private void LoadRounds() { Rounds.Clear(); @@ -201,6 +208,42 @@ namespace TrackerWPFUI.ViewModels //} } + public void ScoreMatch() + { + for (int i = 0; i < SelectedMatchup.Entries.Count; i++) + { + if (i == 0) + { + if (SelectedMatchup.Entries[0].TeamCompeting != null) + { + SelectedMatchup.Entries[0].Score = TeamOneScore; + } + } + + if (i == 1) + { + if (SelectedMatchup.Entries[1].TeamCompeting != null) + { + + SelectedMatchup.Entries[1].Score = TeamTwoScore; + } + + } + } + + try + { + TournamentLogic.UpdateTournamentResults(Tournament); + } + + catch (Exception ex) + { + System.Windows.MessageBox.Show($"The application had the following error :{ex.Message}"); + return; + } + + LoadMatchups(); + } } } diff --git a/TrackerWPFUI/Views/ShellView.xaml b/TrackerWPFUI/Views/ShellView.xaml index e5d4859..c45cdb7 100644 --- a/TrackerWPFUI/Views/ShellView.xaml +++ b/TrackerWPFUI/Views/ShellView.xaml @@ -35,7 +35,9 @@ SelectedItem="{Binding Path=SelectedTournament,Mode=OneWayToSource}"/> - - + + +