Exemple #1
0
        public List <GameResultDto> GetResultsTeamAsDtoAll(string teamCode)
        {
            var query = (from g in _wpbDataContext.GameResults
                         join homeTeam in _wpbDataContext.Teams on g.HomeTeamId equals homeTeam.Id
                         join awayTeam in _wpbDataContext.Teams on g.AwayTeamId equals awayTeam.Id
                         join subDiv in _wpbDataContext.SubDivisions on g.SubDivisionId equals subDiv.Id
                         join div in _wpbDataContext.Divisions on subDiv.DivisionId equals div.Id
                         where g.AwayTeamCode == teamCode || g.HomeTeamCode == teamCode
                         select new GameResultDto
            {
                TimeStamp = g.TimeStamp,
                HomeTeamName = homeTeam.TeamName,
                HomeTeamCode = homeTeam.TeamCode,
                HomeTeamHasLogo = homeTeam.HasLogo,
                HomeTeamLogo = GameResultDto.GetLogolUrl(homeTeam.Logo),
                AwayTeamName = awayTeam.TeamName,
                AwayTeamCode = awayTeam.TeamCode,
                AwayTeamHasLogo = awayTeam.HasLogo,
                AwayTeamLogo = GameResultDto.GetLogolUrl(awayTeam.Logo),
                Division = div.DivisionName,
                DivisionCode = div.DivisionCode,
                SubDivision = subDiv.SubDivisionTitle,
                SubDivisionCode = subDiv.SubDivisionCode,
                Score = g.Score,
                WinnerTeamName = g.WinningTeamName,
                WinnerTeamCode = g.WinningTeamCode
            });

            return(query.ToList());
        }
Exemple #2
0
        public List <GameResultDto> GetResultsAsDto()
        {
            var timestampNow = DateTime.Now;
            //  We only want the "last" 14days
            var timestampSeven = timestampNow.AddDays(-14);

            var query = (from g in _wpbDataContext.GameResults
                         where g.TimeStamp >= timestampSeven
                         join homeTeam in _wpbDataContext.Teams on g.HomeTeamId equals homeTeam.Id
                         join awayTeam in _wpbDataContext.Teams on g.AwayTeamId equals awayTeam.Id
                         join subDiv in _wpbDataContext.SubDivisions on g.SubDivisionId equals subDiv.Id
                         join div in _wpbDataContext.Divisions on subDiv.DivisionId equals div.Id
                         select new GameResultDto
            {
                TimeStamp = g.TimeStamp,
                HomeTeamName = homeTeam.TeamName,
                HomeTeamCode = homeTeam.TeamCode,
                HomeTeamHasLogo = homeTeam.HasLogo,
                HomeTeamLogo = GameResultDto.GetLogolUrl(homeTeam.Logo),
                AwayTeamName = awayTeam.TeamName,
                AwayTeamCode = awayTeam.TeamCode,
                AwayTeamHasLogo = awayTeam.HasLogo,
                AwayTeamLogo = GameResultDto.GetLogolUrl(awayTeam.Logo),
                Division = div.DivisionName,
                DivisionCode = div.DivisionCode,
                SubDivision = subDiv.SubDivisionTitle,
                SubDivisionCode = subDiv.SubDivisionCode,
                Score = g.Score,
                WinnerTeamName = g.WinningTeamName,
                WinnerTeamCode = g.WinningTeamCode
            });

            return(query.ToList());
        }