private void InsertMatches() { if (Competitor == null || Opponents == null || Opponents.Length == 0) { Log.WarnDialog("You must select a competitor and at least one opponent"); return; } if (TimeSetting == null) { Log.WarnDialog("You must select a time control setting"); return; } var competitorId = Competitor.Id; var opponentIds = Opponents.Select(x => x.Id).ToArray(); var timeControlId = TimeSetting.Id; var matches = new List <ScheduledMatch>(); for (int i = 0; i < MatchCount; i++) { for (int j = 0; j < opponentIds.Length; j++) { if (PlayWhite) { matches.Add(new ScheduledMatch { WhiteId = competitorId, BlackId = opponentIds[j], TimeControlId = timeControlId }); } if (PlayBlack) { matches.Add(new ScheduledMatch { WhiteId = opponentIds[j], BlackId = competitorId, TimeControlId = timeControlId }); } } } MasterState.Instance.QueueMatches(matches); }