public void LoadEvents() { this.listEvents.Items.Clear(); var items = new EUFAEntities().MatchEvents .Include(x => x.Match.TournamentParticipation.Team) .Include(x => x.Match.TournamentParticipation1.Team) .OrderBy(x => x.MatchMinute) .AsNoTracking() .Where(x => x.MatchId == _match.Id).ToList(); foreach (var item in items) { var lvi = new ListViewItem(item.MatchMinute.ToString() + "'"); lvi.SubItems.Add(item.TeamA ? item.Match.TournamentParticipation.Team.CountryName : item.Match.TournamentParticipation1.Team.CountryName); lvi.SubItems.Add(MatchEventCode.GetDesc(item.EventType)); lvi.SubItems.Add(item.AdditionalInformation); lvi.Tag = item; this.listEvents.Items.Add(lvi); } }
public AddEditGameEvent(int matchId, int?id) { this.id = id; this.matchId = matchId; InitializeComponent(); var data = new EUFAEntities(); var match = data.Matches .Include(x => x.TournamentParticipation.Team) .Include(x => x.TournamentParticipation1.Team) .AsNoTracking().FirstOrDefault(x => x.Id == matchId); cbEvents.Items.AddRange(MatchEventCode.All.Select(x => new KeyWithView(x, MatchEventCode.GetDesc(x))).ToArray()); rbTeamA.Text = match.TournamentParticipation.Team.CountryCode; rbTeamB.Text = match.TournamentParticipation1.Team.CountryCode; if (this.id != null) { var matchEvent = data.MatchEvents.AsNoTracking().FirstOrDefault(x => x.Id == id); numMinute.Value = matchEvent.MatchMinute; tbAdditionalInformation.Text = matchEvent.AdditionalInformation; cbEvents.SelectedItem = cbEvents.Items.Cast <KeyWithView>().FirstOrDefault(x => (string)x.Key == matchEvent.EventType); rbTeamA.Checked = matchEvent.TeamA; rbTeamB.Checked = !matchEvent.TeamA; } ValidForm(); }