Exemple #1
0
        private void EditPlayerBtn_Click(object sender, RoutedEventArgs e)
        {
            var player = (Player)PlayerList.SelectedItem;

            if (player == null)
            {
                return;
            }

            var addPlayerWindow = new AddPlayerWindow(true, null)
            {
                Player         = player,
                PlayerName     = player.Name,
                PersonalNumber = player.PersonalNumber
            };

            var addPlayerResult = addPlayerWindow.ShowDialog();

            if (!addPlayerResult.HasValue)
            {
                return;
            }

            _personService.Edit(addPlayerWindow.Player, addPlayerWindow.PlayerName, addPlayerWindow.PersonalNumber);
            Players.Remove(addPlayerWindow.Player);
            Players.Add(addPlayerWindow.Player);
        }
Exemple #2
0
        private void AddPlayer_Clicked(object sender, RoutedEventArgs e)
        {
            var playerList      = PlayerList.Items.Cast <Player>().ToList();
            var addPlayerWindow = new AddPlayerWindow(false, playerList);
            var addPlayerResult = addPlayerWindow.ShowDialog();

            if (addPlayerResult.HasValue && !addPlayerResult.Value)
            {
                Trace.WriteLine("we did not press the add buttom");
                return;
            }

            var newPlayer = addPlayerWindow.Player;

            var playerAlreadyExists = _personService.FindPlayerById(newPlayer.Id) != null;

            if (!playerAlreadyExists)
            {
                _personService.Add(newPlayer);
            }
            Players.Add(addPlayerWindow.Player);
        }