private void ButtonRegister_Click(object sender, RoutedEventArgs e) { string username = TextBoxUsername.Text; string password = PasswordBoxPassword.Password; string repeatPassword = PasswordBoxRepeatPassword.Password; if (!isFieldsFilled()) { MessageBox.Show("Please fill in all fields to register", "Information", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (!isRepeatEqualsPassword()) { MessageBox.Show("Secrets must be the same", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } try { Pokedex playerPokedex = Pokedexes.Add(new Pokedex()); Player player = new Player(); player.Password = password; player.Username = username; player.PokedexID = playerPokedex.ID; Players.Add(player); MessageBox.Show("Welcome " + username + "! Now, type your data to enter to the Pokémon world!", "", MessageBoxButton.OK); Close(); } catch { MessageBox.Show("An error has occurred, please try again later.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public IActionResult Register(Player player) { try { Pokedex playerPokedex = Pokedexes.Add(new Pokedex()); player.PokedexID = playerPokedex.ID; Players.Add(player); return(Ok()); } catch (Exception error) { return(StatusCode(500)); } }