Ejemplo n.º 1
0
        private async void getData(Match m)
        {
            PlayerListVM plvm = PlayerListVM.getInstance();
            var          tlvm = TournamentListVM.getInstance();


            tournament = tlvm.Tournaments.Where(t =>
            {
                return(t.ID == m.TournamentId);
            }).Single();

            team1Player1 = plvm.Players.Where(t =>
            {
                return(t.ID == m.Team1Player1);
            }).Single();

            team1Player2 = plvm.Players.Where(t =>
            {
                return(t.ID == m.Team1Player2);
            }).Single();

            team2Player1 = plvm.Players.Where(t =>
            {
                return(t.ID == m.Team2Player1);
            }).Single();

            team2Player2 = plvm.Players.Where(t =>
            {
                return(t.ID == m.Team2Player2);
            }).Single();
        }
Ejemplo n.º 2
0
        public MatchVM(Match m)
        {
            playerList     = new ObservableCollection <PlayerVM>();
            tournamentList = new ObservableCollection <TournamentVM>();


            foreach (PlayerVM p in PlayerListVM.getInstance().Players)
            {
                playerList.Add(p);
            }
            var tlvm = TournamentListVM.getInstance();

            tournamentList = new ObservableCollection <TournamentVM>(tlvm.
                                                                     Tournaments.Where(tourn => tourn.Timestamp >= DateTime.Today || tourn.ID == m.TournamentId));

            currentMatch = m;
            getData(m);

            ID = m.ID;
            Team1Player1.ID     = m.Team1Player1;
            Team1Player2.ID     = m.Team1Player2;
            Team2Player1.ID     = m.Team2Player1;
            Team2Player2.ID     = m.Team2Player2;
            Finished            = m.Finished;
            Tournament.ID       = m.TournamentId;
            ResultPointsPlayer1 = m.ResultPointsPlayer1;
            ResultPointsPlayer2 = m.ResultPointsPlayer2;
        }
Ejemplo n.º 3
0
 public static TournamentListVM getInstance()
 {
     if (instance == null)
     {
         instance = new TournamentListVM();
     }
     return(instance);
 }
Ejemplo n.º 4
0
        private async void Create(Tournament currentTournament)
        {
            TournamentListVM.getInstance().Tournaments.Insert(0, new TournamentVM(currentTournament));

            HttpClient client = new HttpClient();
            string     json   = JsonConvert.SerializeObject(currentTournament);

            client.DefaultRequestHeaders.Add("Authorization", Authentication.token.Token);
            var httpContent = new StringContent(json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.PostAsync(BASE_URL + "api/tournaments/", httpContent);

            Debug.WriteLine(response.Content);

            MainWindow.main.Content = new TournamentList();
        }
Ejemplo n.º 5
0
        private async void LoadAgenda()
        {
            ObservableCollection <MatchVM> agendaList = new ObservableCollection <MatchVM>();
            var list = new ObservableCollection <MatchVM>();
            IEnumerable <MatchVM> listMatchIEn;

            agendaList.Clear();

            string     json;
            HttpClient client = new HttpClient();

            json = await client.GetStringAsync(BASE_URL + "api/matches/list/agenda");


            ObservableCollection <Match> matches = JsonConvert.DeserializeObject <ObservableCollection <Match> >(json);
            await TournamentListVM.getInstance().LoadTournaments();

            foreach (var m in matches)
            {
                list.Add(new MatchVM(m));
            }

            listMatchIEn = list.Where(m =>
            {
                return(m.Tournament.Timestamp >= DateTime.Today &&
                       m.ResultPointsPlayer1 == null &&
                       m.ResultPointsPlayer2 == null);
            });

            foreach (MatchVM m in listMatchIEn)
            {
                agendaList.Add(m);
            }
            AgendaList.Clear();
            foreach (var m in agendaList.Where(m => m.Tournament.Timestamp >= DateTime.Today).Where(m => m.Finished == false))
            {
                AgendaList.Add(m);
            }

            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(AgendaList)));
        }
Ejemplo n.º 6
0
        public async void LoadMatches()
        {
            Matches.Clear();
            matchesList.Clear();

            string     json;
            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Add("Authorization", Authentication.token.Token);
            json = await client.GetStringAsync(BASE_URL + "api/matches");


            ObservableCollection <Match> matches = JsonConvert.DeserializeObject <ObservableCollection <Match> >(json);
            var tlvm = TournamentListVM.getInstance();
            await tlvm.LoadTournaments();

            foreach (var m in matches)
            {
                matchesList.Add(new MatchVM(m));
            }

            Matches = matchesList.OrderByDescending(m => m.Tournament.Timestamp).ToList();
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Matches)));
        }