Esempio n. 1
0
 public PlayerShow(Player _handle)
 {
     handle = _handle;
     InitializeComponent();
     MediaTypeNames.Text = handle.Name;
     nameLabel.Text = handle.Name;
     nationalityLabel.Text = handle.Nationality;
     teamsLabel.Text += handle.Teams.Name+" ; ";
 }
Esempio n. 2
0
 public PlayerCreate(Player _handler)
 {
     handler = _handler;
     InitializeComponent();
     foreach (Team team in teamRepository.GetAll())
     {
         teamsCombo.Items.Add(team);
     }
     nameInput.Text = handler.Name;
     teamsCombo.SelectedItem = handler.Teams;
     nationalityInput.Text = handler.Nationality;
 }
Esempio n. 3
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                if (handler == null)
                {

                    Player newPlayer = new Player();
                    newPlayer.Nationality = nationalityInput.Text;
                    //if (newPlayer.Teams == null) newPlayer.Teams = new List<Team>();
                    Team selectedTeam = (Team) teamsCombo.SelectedItem;
                    newPlayer.Teams=(selectedTeam);
                   // selectedTeam.Players.Add(newPlayer);
                   // teamRepository.SaveOrUpdate(selectedTeam);

                    newPlayer.Name = nameInput.Text;

                    repo.SaveOrUpdate(newPlayer);
                    DialogResult result = MetroMessageBox.Show(this, "Player created!", "Success!", MessageBoxButtons.OK,
                        MessageBoxIcon.Information);
                    if (result == DialogResult.OK)
                    {

                    }
                }
                else
                {
                    Team originalTeam = handler.Teams;
                    originalTeam.Players.Remove(handler);
                    teamRepository.SaveOrUpdate(originalTeam);
                    handler.Nationality = nationalityInput.Text;
                    handler.Teams = null;
                    Team selectedTeam = (Team)teamsCombo.SelectedItem;
                    handler.Teams = selectedTeam;
            //                    selectedTeam.Players.Add(handler);
                    teamRepository.SaveOrUpdate(selectedTeam);
            //                    repo.SaveOrUpdate(handler);
                }

            }
            else
            {
                MetroMessageBox.Show(this, "Sorry, data is not valid.", "Validation error", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);

            }
        }
Esempio n. 4
0
 internal IList<Player> FromTeamsPlayers(TeamsPlayersResponse result)
 {
     List<Player> ret = new List<Player>();
     foreach(var apiPlayer in result.Players)
     {
         var x = new Player();
         x.Name = apiPlayer.Name;
         x.Nationality = apiPlayer.Nationality;
         ret.Add(x);
     }
     return ret;
 }