private void BtnProfile_Click(object sender, RoutedEventArgs e) { if (_isGame) { MessageBox.Show("At first you must end the game!"); return; } this.Hide(); ProfileWindow profile = new ProfileWindow(_hostUrl); profile.Owner = this; profile.ShowDialog(); if (MainWindow.playerLogin == "none" && MainWindow.playerPassword == "none") { this.Close(); return; } requestUrl = _hostUrl + $"/api/jsstudygame/login?emailOrLogin={MainWindow.playerLogin}&password={MainWindow.playerPassword}"; _player = ServerWorker.GetInfoFromServer <PlayerVM>(requestUrl); requestUrl = _hostUrl + $"/api/jsstudygame/addinfo?login={MainWindow.playerLogin}&password={MainWindow.playerPassword}"; _playerAddInfo = ServerWorker.GetInfoFromServer <PlayerAdditionalInfoVM>(requestUrl); requestUrl = _hostUrl + $"/api/jsstudygame/score?login={MainWindow.playerLogin}&password={MainWindow.playerPassword}"; _playerScore = ServerWorker.GetInfoFromServer <PlayerScoreVM>(requestUrl); _playerScore.IdPlayerScore = _player.Id; this.ShowDialog(); }
private void BtnChange_Click(object sender, RoutedEventArgs e) { if (!(dgShow.SelectedItem is PlayerFullInfo)) { dgShow.SelectedItem = null; return; } string login = MainWindow.playerLogin; string password = MainWindow.playerPassword; MainWindow.playerLogin = ((PlayerFullInfo)dgShow.SelectedItem).Login; MainWindow.playerPassword = ((PlayerFullInfo)dgShow.SelectedItem).Password; this.Hide(); ProfileWindow profile = new ProfileWindow(_hostUrl); profile.Owner = this; profile.ShowDialog(); var currentPlayer = _playersFullInfo.SingleOrDefault(p => p.Login == MainWindow.playerLogin && p.Password == MainWindow.playerPassword); var requestUrl = _hostUrl + $"/api/jsstudygame/login?emailOrLogin={MainWindow.playerLogin}&password={MainWindow.playerPassword}"; var player = ServerWorker.GetInfoFromServer <PlayerVM>(requestUrl); requestUrl = _hostUrl + $"/api/jsstudygame/addinfo?login={MainWindow.playerLogin}&password={MainWindow.playerPassword}"; var playerAddInfo = ServerWorker.GetInfoFromServer <PlayerAdditionalInfoVM>(requestUrl); currentPlayer.Id = player.Id; currentPlayer.Password = player.Password; currentPlayer.Email = player.Email; currentPlayer.Login = player.Login; currentPlayer.IsAdmin = player.IsAdmin; currentPlayer.Name = playerAddInfo.Name; currentPlayer.Surname = playerAddInfo.Surname; currentPlayer.Photo = _hostUrl + $"/photos/{playerAddInfo.Photo}"; currentPlayer.BirthDate = playerAddInfo.BirthDate; currentPlayer.Gender = playerAddInfo.Gender == true ? "male" : "female"; MainWindow.playerLogin = login; MainWindow.playerPassword = password; this.ShowDialog(); }