private void homePlayerInput1_TextChanged(object sender, EventArgs e) { try { var playerNumber = Convert.ToInt32(homePlayerInput1.Text); _homePlayer = playerService.GetPlayerByPlayerNumber(playerNumber, Home); if (_homePlayer != null) { homePlayerLabel1.Text = _homePlayer.Name; if (GetLiveData.Checked) { bw = new BackgroundWorker(); bw.WorkerSupportsCancellation = true; bw.DoWork += new DoWorkEventHandler(GetHomePlayerData); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(FillInPlayerLabelsHome); bw.RunWorkerAsync(); } else { BlankHomePlayerStatLines(); } } else { homePlayerLabel1.Text = ""; } } catch (Exception er) { homePlayerLabel1.Text = ""; BlankHomePlayerStatLines(); } }
public Models.Team.Player GetPlayerByPlayerNumber(int playerNum, Team team) { var returnPlayer = new Team.Player(); return team.Players.Where(x => x.Number == playerNum).SingleOrDefault(); }