Example #1
0
        /// <summary>
        /// Fonction appelée quand l'utilisateur veut se connecter et que ses informations sont correct.
        /// </summary>
        /// <param name="parameters">Command parameter</param>
        public async void GoToMain(object parameters)
        {
            IsLoading = true;
            if (Login.Validate())
            {
                var user = (Player)await _authentificationService.Authentificate(new Player { Login = Login.Pseudo.Value, Password = Login.Password.Value });

                if (user.JwtToken != null)
                {
                    var navigationParams = new NavigationParameters();
                    navigationParams.Add("player", user);
                    IsLoading = false;
                    App.User  = new ViewPlayer {
                        Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, Login = user.Login, Picture = user.Picture, TeamPlayers = user.TeamPlayers.Select(tp => new ViewTeamPlayer {
                            IdPlayer = tp.IdPlayer, IdTeam = tp.IdTeam
                        }).ToList()
                    };
                    await this.NavigationService.NavigateAsync(nameof(MainPage), navigationParams);
                }
            }
        }