Пример #1
0
        public ClubPlayerHistoryViewModel GetClubPlayerHistory(int clubId)
        {
            var result = new ClubPlayerHistoryViewModel();

            result.club = Database.Instance.clubRepository.GetClubById(clubId);

            if (result.club == null)
            {
                return(null);
            }

            List <int> clubIds = GetClubIds(result.club);

            result.players = Database.Instance.playerRepository.GetPlayersFromClubs(clubIds);
            result.seasons = Database.Instance.clubRepository.GetClubsSeasons(clubIds);

            result.headings = new List <SortOptions>();
            result.headings.Add(new SortOptions("Bondsnr", "Bondsnummer", _attributes: "class='nr'"));
            result.headings.Add(new SortOptions(_displayField: "Speler", _sortField: "Speler", _isDefaultSortColumn: true, _attributes: "class='name'"));
            result.headings.Add(new SortOptions("Seizoenen", "Seizoenen", _defaultSortOrder: "Aflopend"));

            int seasonYear    = result.seasons[result.seasons.Count() - 1].seasonYear;
            int seasonYearEnd = result.seasons[0].seasonYear;

            while (seasonYear <= seasonYearEnd)
            {
                result.headings.Add(new SortOptions("vj", "vj" + seasonYear, _attributes: "class='season'"));
                result.headings.Add(new SortOptions("nj", "nj" + seasonYear, _attributes: "class='season'"));

                seasonYear++;
            }

            return(result);
        }
Пример #2
0
        private ClubPlayerHistoryViewModel GetTeamMemberHistory(List <TeamListViewModel> teams, string playerNumber)
        {
            var history = new ClubPlayerHistoryViewModel();

            history.players = new List <PlayerHistoryViewModel>();
            history.seasons = new List <SeasonListViewModel>();

            foreach (var team in teams)
            {
                foreach (var player in team.teamMembers)
                {
                    if (player.playerNumber.Equals(playerNumber))
                    {
                        continue;
                    }

                    var playerHistory = history.players.SingleOrDefault(p => p.playerNumber.Equals(player.playerNumber));

                    if (playerHistory == null)
                    {
                        playerHistory              = new PlayerHistoryViewModel();
                        playerHistory.playerName   = player.playerName;
                        playerHistory.playerNumber = player.playerNumber;
                        playerHistory.seasons      = new List <SeasonViewModel>();

                        history.players.Add(playerHistory);
                    }

                    if (playerHistory.seasons.Count(s => s.seasonPeriod == team.seasonPeriod && s.seasonYear == team.seasonYear) == 0)
                    {
                        playerHistory.seasons.Add(new SeasonViewModel()
                        {
                            seasonPeriod = team.seasonPeriod, seasonYear = team.seasonYear
                        });
                    }

                    if (history.seasons.Count(s => s.seasonPeriod == team.seasonPeriod && s.seasonYear == team.seasonYear) == 0)
                    {
                        history.seasons.Add(new SeasonListViewModel()
                        {
                            seasonPeriod = team.seasonPeriod, seasonYear = team.seasonYear
                        });
                    }
                }
            }

            history.headings = new List <SortOptions>();
            history.headings.Add(new SortOptions("Bondsnr", "Bondsnummer", _attributes: "class='nr'"));
            history.headings.Add(new SortOptions("Speler", "Speler", _attributes: "class='name'"));
            history.headings.Add(new SortOptions("Seizoenen", "Seizoenen", _defaultSortOrder: "Aflopend"));

            if (history.seasons.Count() > 0)
            {
                int seasonYear    = history.seasons[history.seasons.Count() - 1].seasonYear;
                int seasonYearEnd = history.seasons[0].seasonYear;

                while (seasonYear <= seasonYearEnd)
                {
                    history.headings.Add(new SortOptions("vj", "vj" + seasonYear, _attributes: "class='season'"));
                    history.headings.Add(new SortOptions("nj", "nj" + seasonYear, _attributes: "class='season'"));

                    seasonYear++;
                }
            }

            return(history);
        }