Exemplo n.º 1
0
        public async Task <IEnumerable <TeamLineUp> > GetTeamMatchup(string teamId1, string teamId2)
        {
            var teamCollection = _team.GetMongoDbCollection("Team");

            var teamPlayerCollection = _teamPlayers.GetMongoDbCollection("TeamPlayers");

            var teams = await teamCollection.FindAsync(Builders <Team> .Filter.Where(cn => cn.Id == teamId1 || cn.Id == teamId2)).Result.ToListAsync();

            var teamPlayers = await teamPlayerCollection.FindAsync(Builders <TeamPlayer> .Filter.Where(cn => cn.TeamId == teamId1 || cn.TeamId == teamId2)).Result.ToListAsync();

            var teamLineups = new List <TeamLineUp>();

            var query = teams.GroupJoin(teamPlayers, tp => tp.Id, t => t.TeamId, (t, tp) => new
            {
                TeamId      = t.Id,
                TeamName    = t.Name,
                TeamPlayers = tp.Select(s => s.PlayerName)
            });

            var teamLineupMatch = new List <TeamLineUp>();

            foreach (var obj in query)
            {
                var teamLineup = new TeamLineUp();

                teamLineup.TeamId   = obj.TeamId;
                teamLineup.TeamName = obj.TeamName;

                var tmPlayers = new List <TeamLineUpPlayers>();

                foreach (var players in obj.TeamPlayers)
                {
                    tmPlayers.Add(new TeamLineUpPlayers()
                    {
                        PlayerName = players
                    });
                }

                teamLineup.TeamPlayer = tmPlayers;

                teamLineupMatch.Add(teamLineup);
            }



            return(await Task.FromResult(teamLineupMatch));
        }
Exemplo n.º 2
0
        public async Task <TeamLineUp> GetTeamandPlayers()
        {
            var teamPlayers = await _genericTeamPlayerRepository.GetAll("TeamPlayers");

            var teamplayerlist = teamPlayers.ToList();

            var teams = await _genericTeamRepository.GetAll("Team");

            var teamlist = teams;

            var unique = teamPlayers.GroupBy(o => new { o.PlayerName, o.PubgAccountId }).Select(o => o.FirstOrDefault());

            var query = teamlist.GroupJoin(unique, tp => tp.Id, t => t.TeamId, (t, tp) => new
            {
                TeamId      = t.Id,
                TeamName    = t.Name,
                TeamPlayers = tp.Select(s => s.PlayerName)
            });

            var teamlineup = new TeamLineUp();

            var teamlineplayers = new List <TeamLineUpPlayers>();

            foreach (var teamplayer in query)
            {
                teamlineup.TeamId = teamplayer.TeamId;

                teamlineup.TeamName = teamplayer.TeamName;

                foreach (var player in teamplayer.TeamPlayers)
                {
                    teamlineplayers.Add(new TeamLineUpPlayers {
                        PlayerName = player
                    });
                }
                teamlineup.TeamPlayer = teamlineplayers;
            }

            var result = teamlineup;

            return(result);
        }
Exemplo n.º 3
0
        public Task <TeamLineUp> GetTeamLine(int teamId)
        {
            var teams = _team.GetAll("Team").Result;

            var teamPlayers = _teamPlayers.GetAll("TeamPlayers").Result;

            var query = teams.GroupJoin(teamPlayers, tp => tp.TeamId, t => t.TeamIdShort, (t, tp) => new
            {
                teamid = t.TeamId,

                TeamName = t.Name,

                TeamPlayers = tp.Select(s => new { s.TeamIdShort, s.PlayerName, s.PlayerId }).Distinct()
            }).Where(t => t.teamid == teamId);

            var teamlineup = new TeamLineUp();

            var teamplayer = new List <TeamLineUpPlayers>();

            foreach (var obj in query)
            {
                teamlineup.TeamId = obj.teamid.ToString();

                teamlineup.TeamName = obj.TeamName;

                foreach (var players in obj.TeamPlayers)
                {
                    teamplayer.Add(new TeamLineUpPlayers()
                    {
                        PlayerName = players.PlayerName, TeamId = players.TeamIdShort, PlayerId = players.PlayerId
                    });
                }

                teamlineup.TeamPlayer = teamplayer;
            }

            return(Task.FromResult(teamlineup));
        }