Ejemplo n.º 1
0
        public IEnumerable <Player> GetTeamOfTheWeek()
        {
            var allTeams       = _mongoTeamProvider.GetAll().Result;
            var allTeamPlayers = new List <Player>();

            foreach (var team in allTeams)
            {
                allTeamPlayers.AddRange(GetPlayersForTeam(team.Id));
            }

            var teamOfTheWeek = new List <Player>();

            var goalkeeper = allTeamPlayers.Where(x => x.Position == 1).OrderByDescending(x => x.RecentPoints).ThenByDescending(x => x.TotalPoints).FirstOrDefault();

            teamOfTheWeek.Add(goalkeeper);

            var playersToAdd = new List <Player>();

            var defenders = allTeamPlayers.Where(x => x.Position == 2).OrderByDescending(x => x.RecentPoints).ThenByDescending(x => x.TotalPoints).Take(5).ToList();

            playersToAdd.AddRange(defenders);

            var midfielders = allTeamPlayers.Where(x => x.Position == 3).OrderByDescending(x => x.RecentPoints).ThenByDescending(x => x.TotalPoints).Take(5).ToList();

            playersToAdd.AddRange(midfielders);

            var forwards = allTeamPlayers.Where(x => x.Position == 4).OrderByDescending(x => x.RecentPoints).ThenByDescending(x => x.TotalPoints).Take(3).ToList();

            playersToAdd.AddRange(forwards);

            var highestScoringOutfieldPlayers = GetValidTeamOfWeekPlayers(playersToAdd.OrderByDescending(x => x.RecentPoints).ThenByDescending(x => x.TotalPoints).ToList());

            teamOfTheWeek.AddRange(highestScoringOutfieldPlayers);

            return(teamOfTheWeek.OrderBy(x => x.Position));
        }
Ejemplo n.º 2
0
 public IEnumerable <Team> GetAllTeams()
 {
     return(_mongoTeamProvider.GetAll().Result);
 }