Пример #1
0
        public async void  ChargeVar()
        {
            UsersServices       usersServices       = new UsersServices();
            TournamentsServices tournamentsServices = new TournamentsServices();
            long idTounrnament = Tournament.Id;
            var  responseUser  = await tournamentsServices.GetParticipants(idTounrnament);

            var responseArbitre = await usersServices.GetUsersWithAccount();

            bool allRequestSuccess = true;

            if (responseUser.Success)
            {
                List <User> users = ((List <Object>)responseUser.Content).Cast <User>().ToList();
                AllUsers = new ObservableCollection <User>(users);
            }
            else
            {
                allRequestSuccess = false;
            }
            if (responseArbitre.Success)
            {
                List <User> arbitres = ((List <object>)responseArbitre.Content).Cast <User>().ToList();
                AllArbitre = new ObservableCollection <User>(arbitres);
            }
            else
            {
                allRequestSuccess = false;
            }



            if (allRequestSuccess)
            {
                //if(Match.Arbitre != null)
                //    SelectedArbitre = AllArbitre.Where(a => a.Id == Match.Arbitre.Id);
                if (Match.Player1 != null)
                {
                    SelectedJoueur1 = AllUsers.Where(u => u.Id == Match.Player1.Id).First();
                }
                if (Match.Player2 != null)
                {
                    SelectedJoueur2 = AllUsers.Where(u => u.Id == Match.Player2.Id).First();
                }
                HeurePrevue = Match.Time;
                LieuMatch   = Match.Emplacement;
            }
        }
Пример #2
0
        public async Task  ChargeVar()
        {
            UsersServices       usersServices       = new UsersServices();
            TournamentsServices tournamentsServices = new TournamentsServices();
            long idTounrnament     = Tournament.Id;
            bool allRequestSuccess = true;

            try
            {
                List <User> users = await tournamentsServices.GetParticipants(idTounrnament);

                AllUsers = new ObservableCollection <User>(users);
                List <User> arbitres = await usersServices.GetUsersWithAccount();

                AllArbitre = new ObservableCollection <User>(arbitres);
            }
            catch (Exception e)
            {
                allRequestSuccess = false;
                SetGeneralErrorMessage(e);
            }

            if (allRequestSuccess)
            {
                if (Match.Arbitre != null)
                {
                    SelectedArbitre = AllArbitre.Where(a => a.Id == Match.Arbitre.Id).DefaultIfEmpty(null).First();
                }
                if (Match.Player1 != null)
                {
                    SelectedJoueur1 = AllUsers.Where(u => u.Id == Match.Player1.Id).First();
                }
                if (Match.Player2 != null)
                {
                    SelectedJoueur2 = AllUsers.Where(u => u.Id == Match.Player2.Id).First();
                }
                HeurePrevue = Match.Time;
                LieuMatch   = Match.Emplacement;
            }
        }