コード例 #1
0
        public static TeamsExcelCreator CreateFormation(TeamEntity[] teams, List <MatchEntity> matches, PlayerEntity[] players, ClubEntity[] clubs)
        {
            var result = new List <TeamExcelModel>();

            foreach (var team in teams.OrderByDescending(x => x.Competition).ThenBy(x => x.TeamCode))
            {
                var teamModel = new TeamExcelModel(team.Competition + " " + team.TeamCode);

                foreach (var teamPlayer in team.Players)
                {
                    var player = players.First(x => x.Id == teamPlayer.PlayerId);
                    teamModel.Players.Add(new TeamPlayerExcelModel(player.NaamKort, teamPlayer.PlayerType));
                }

                foreach (var match in matches.Where(x => x.FrenoyDivisionId == team.FrenoyDivisionId).OrderBy(x => x.Date))
                {
                    if (match.AwayClubId == 0 || match.HomeClubId == 0)
                    {
                        // 'vrije' week
                        continue;
                    }

                    var teamMatch = new TeamMatchExcelModel(match, clubs);
                    foreach (var matchPlayer in match.Players.Where(x => x.Status != PlayerMatchStatus.Captain && x.Status != PlayerMatchStatus.Major))
                    {
                        if (!teamMatch.PlayerDecisions.ContainsKey(matchPlayer.Name))
                        {
                            teamMatch.PlayerDecisions.Add(matchPlayer.Name, matchPlayer.Status);
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(match.Block))
                    {
                        foreach (var matchPlayer in match.Players.Where(x => x.Status == match.Block))
                        {
                            if (!teamMatch.CaptainDecisions.Contains(matchPlayer.Name))
                            {
                                teamMatch.CaptainDecisions.Add(matchPlayer.Name);
                            }
                        }
                    }

                    teamModel.Matches.Add(teamMatch);
                }

                result.Add(teamModel);
            }

            return(new TeamsExcelCreator(result));
        }
コード例 #2
0
        public static TeamsExcelCreator CreateFormation(TeamEntity[] teams, List<MatchEntity> matches, PlayerEntity[] players, ClubEntity[] clubs)
        {
            var result = new List<TeamExcelModel>();
            foreach (var team in teams.OrderByDescending(x => x.Competition).ThenBy(x => x.TeamCode))
            {
                var teamModel = new TeamExcelModel(team.Competition + " " + team.TeamCode);

                foreach (var teamPlayer in team.Players)
                {
                    var player = players.First(x => x.Id == teamPlayer.PlayerId);
                    teamModel.Players.Add(new TeamPlayerExcelModel(player.NaamKort, teamPlayer.PlayerType));
                }

                foreach (var match in matches.Where(x => x.FrenoyDivisionId == team.FrenoyDivisionId).OrderBy(x => x.Date))
                {
                    var teamMatch = new TeamMatchExcelModel(match, clubs);
                    foreach (var matchPlayer in match.Players.Where(x => x.Status != PlayerMatchStatus.Captain && x.Status != PlayerMatchStatus.Major))
                    {
                        if (!teamMatch.PlayerDecisions.ContainsKey(matchPlayer.Name))
                        {
                            teamMatch.PlayerDecisions.Add(matchPlayer.Name, matchPlayer.Status);
                        }
                    }
                    if (!string.IsNullOrWhiteSpace(match.Block))
                    {
                        foreach (var matchPlayer in match.Players.Where(x => x.Status == match.Block))
                        {
                            if (!teamMatch.CaptainDecisions.Contains(matchPlayer.Name))
                            {
                                teamMatch.CaptainDecisions.Add(matchPlayer.Name);
                            }
                        }
                    }

                    teamModel.Matches.Add(teamMatch);
                }

                result.Add(teamModel);
            }

            return new TeamsExcelCreator(result);
        }