Пример #1
0
        ///  <summary>
        ///  Get game info use for many page : 8-1, 8-2, 8-5-1, 8-6 Top and Bottom, Home,...
        ///  </summary>
        /// <param name="gameDate">GameDate.</param>
        ///  <param name="occasionNo">occasionNo.(節)</param>
        ///  <param name="teamId">TeamID.</param>
        ///  <param name="gameId">GameID.</param>
        ///  <param name="lstGameId">List GameID.</param>
        /// <param name="leagueType">leagueType.(1:JリーグTOP / 2:J1TOP / 3:J2TOP)</param>
        /// <param name="round"></param>
        /// <param name="withScoreDetails"></param>
        /// <param name="memberId"></param>
        /// <returns>List game for each condition.</returns>
        public IEnumerable<JlgGameInfos> GetGameInfo(int? gameDate, int? occasionNo, int? teamId, int? gameId,
                                                     List<int> lstGameId, int? leagueType = 0, int? round = 0,
                                                     bool withScoreDetails = false, long memberId = -1, int seasonId = 0)
        {
            var result = new List<JlgGameInfos>();
            var query = default(IEnumerable<JlgGameInfos>);
            var queryFirst = default(IQueryable<JlgGameInfoByCondidtion>);
            bool isValue = true;

            if (lstGameId == null)
            {
                isValue = false;
                lstGameId = new List<int>();
            }

            switch (leagueType)
            {
                case 0:
                    queryFirst = from si in jlg.ScheduleInfo
                                 join gcat in jlg.GameCategory on si.GameCategoryId equals gcat.GameCategoryId
                                 join gs in jlg.GameSchedule on gcat.GameScheduleId equals gs.GameScheduleId
                                 where (gameDate == null || si.GameDate == gameDate)
                                 && (occasionNo == null || si.OccasionNo == occasionNo)
                                 && (round == 0 || si.Round == round)
                                 && (seasonId == 0 || gcat.SeasonID == seasonId)
                                 && (teamId == null || si.HomeTeamID == teamId || si.AwayTeamID == teamId)
                                 && (si.GameID == gameId || gameId == null)
                                 && (!isValue || lstGameId.Contains(si.GameID))
                                 where (gs.GameKindID == JlgConstants.JLG_GAMEKIND_J1 || gs.GameKindID == JlgConstants.JLG_GAMEKIND_J2 || gs.GameKindID == JlgConstants.JLG_GAMEKIND_NABISCO)
                                 select new JlgGameInfoByCondidtion()
                                 {
                                     ScheduleInfoJlg = si,
                                     GameKindID = gs.GameKindID,
                                     GameKindName = gs.GameKindName,
                                     SeasonId = gcat.SeasonID
                                 };
                    break;
                case 1:
                    queryFirst = from si in jlg.ScheduleInfo
                                 join gcat in jlg.GameCategory on si.GameCategoryId equals gcat.GameCategoryId
                                 join gs in jlg.GameSchedule on gcat.GameScheduleId equals gs.GameScheduleId
                                 where (gameDate == null || si.GameDate == gameDate)
                                 && (occasionNo == null || si.OccasionNo == occasionNo)
                                 && (round == 0 || si.Round == round)
                                 && (seasonId == 0 || gcat.SeasonID == seasonId)
                                 && (teamId == null || si.HomeTeamID == teamId || si.AwayTeamID == teamId)
                                 && (si.GameID == gameId || gameId == null)
                                 && (!isValue || lstGameId.Contains(si.GameID))
                                 where (gs.GameKindID == JlgConstants.JLG_GAMEKIND_J1)
                                 select new JlgGameInfoByCondidtion
                                 {
                                     ScheduleInfoJlg = si,
                                     GameKindID = gs.GameKindID,
                                     GameKindName = gs.GameKindName,
                                     SeasonId = gcat.SeasonID
                                 };

                    break;
                case 2:
                    queryFirst = from si in jlg.ScheduleInfo
                                 join gcat in jlg.GameCategory on si.GameCategoryId equals gcat.GameCategoryId
                                 join gs in jlg.GameSchedule on gcat.GameScheduleId equals gs.GameScheduleId
                                 where (gameDate == null || si.GameDate == gameDate)
                                 && (occasionNo == null || si.OccasionNo == occasionNo)
                                 && (round == 0 || si.Round == round)
                                 && (seasonId == 0 || gcat.SeasonID == seasonId)
                                 && (teamId == null || si.HomeTeamID == teamId || si.AwayTeamID == teamId)
                                 && (si.GameID == gameId || gameId == null)
                                 && (!isValue || lstGameId.Contains(si.GameID))
                                 where (gs.GameKindID == JlgConstants.JLG_GAMEKIND_J2)
                                 select new JlgGameInfoByCondidtion
                                 {
                                     ScheduleInfoJlg = si,
                                     GameKindID = gs.GameKindID,
                                     GameKindName = gs.GameKindName,
                                     SeasonId = gcat.SeasonID
                                 };
                    break;
                case 3:
                    queryFirst = from si in jlg.ScheduleInfo
                                 join gcat in jlg.GameCategory on si.GameCategoryId equals gcat.GameCategoryId
                                 join gs in jlg.GameSchedule on gcat.GameScheduleId equals gs.GameScheduleId
                                 where (gameDate == null || si.GameDate == gameDate)
                                 && (occasionNo == null || si.OccasionNo == occasionNo)
                                 && (round == 0 || si.Round == round)
                                 && (seasonId == 0 || gcat.SeasonID == seasonId)
                                 && (teamId == null || si.HomeTeamID == teamId || si.AwayTeamID == teamId)
                                 && (si.GameID == gameId || gameId == null)
                                 && (!isValue || lstGameId.Contains(si.GameID))
                                 where (gs.GameKindID == JlgConstants.JLG_GAMEKIND_NABISCO)
                                 select new JlgGameInfoByCondidtion
                                 {
                                     ScheduleInfoJlg = si,
                                     GameKindID = gs.GameKindID,
                                     GameKindName = gs.GameKindName,
                                     SeasonId = gcat.SeasonID
                                 };
                    break;

            }

            //Continue get extra info for game.
            if (queryFirst == null || !queryFirst.Any())
            {
                query = null;
            }
            else
            {
                query = (from q in queryFirst
                         join ti in jlg.TeamIconJlg on q.ScheduleInfoJlg.HomeTeamID equals ti.TeamCD into htic
                         from hti in htic.DefaultIfEmpty()
                         join ti1 in jlg.TeamIconJlg on q.ScheduleInfoJlg.AwayTeamID equals ti1.TeamCD into atic
                         from ati in atic.DefaultIfEmpty()
                         join osh1 in jlg.RankReportRT on new { q1 = q.GameKindID, q2 = q.SeasonId } equals new { q1 = osh1.GameKindID, q2 = osh1.SeasonID } into hrr
                         from hrpt in hrr.DefaultIfEmpty()
                         join os1 in jlg.RankInfoRT on new { q1 = (int)q.ScheduleInfoJlg.HomeTeamID.Value, q2 = hrpt.RankReportRTId } equals new { q1 = (int)os1.TeamID, q2 = os1.RankReportRTId } into rir1
                         from hrir in rir1.DefaultIfEmpty()
                         join grl in jlg.GameReportLG on new { q1 = q.ScheduleInfoJlg.GameID, q2 = q.SeasonId } equals new { q1 = grl.GameID, q2 = grl.SeasonID } into grl1
                         from grpl in grl1.DefaultIfEmpty()
                         join ht1 in jlg.TeamInfoLG on new { k1 = grpl.GameReportLGId, k2 = (int)q.ScheduleInfoJlg.HomeTeamID.Value } equals new { k1 = ht1.GameReportLGId, k2 = ht1.ID } into htl1
                         from htil in htl1.DefaultIfEmpty()
                         join at1 in jlg.TeamInfoLG on new { k1 = grpl.GameReportLGId, k2 = (int)q.ScheduleInfoJlg.AwayTeamID.Value } equals new { k1 = at1.GameReportLGId, k2 = at1.ID } into atl1
                         from atil in atl1.DefaultIfEmpty()
                         join osh2 in jlg.RankReportRT on new { q1 = q.GameKindID, q2 = q.SeasonId } equals new { q1 = osh2.GameKindID, q2 = osh2.SeasonID } into arr
                         from arpt in arr.DefaultIfEmpty()
                         join os2 in jlg.RankInfoRT on new { k1 = (int)q.ScheduleInfoJlg.AwayTeamID.Value, k2 = arpt.RankReportRTId } equals new { k1 = (int)os2.TeamID, k2 = os2.RankReportRTId } into rir2
                         from arir in rir2.DefaultIfEmpty()
                         join sehe in jlg.ScheduleInfoHE on q.ScheduleInfoJlg.GameID equals sehe.GameID into sehec
                         from sehei in sehec.DefaultIfEmpty()
                         select new JlgGameInfos
                         {
                             GameID = q.ScheduleInfoJlg.GameID,
                             GameDate = (int)q.ScheduleInfoJlg.GameDate,
                             Time = q.ScheduleInfoJlg.GameTime.ToString(),
                             StadiumName = q.ScheduleInfoJlg.StadiumName,
                             GameKindID = q.GameKindID,
                             GameKindName = q.GameKindName,
                             HomeTeamID = q.ScheduleInfoJlg.HomeTeamID.Value,
                             HomeTeamName = q.ScheduleInfoJlg.HomeTeamName ?? string.Empty,
                             HomeTeamNameS = q.ScheduleInfoJlg.HomeTeamNameS ?? string.Empty,
                             HomeTeamIcon = hti.TeamIcon ?? string.Empty,
                             HomeTeamRanking = hrir.Ranking != null ? hrir.Ranking : 0,
                             HomeTeamWin = sehei.HomeWin ?? 0,
                             HomeTeamR = htil.Score,
                             HomeTeamScore = htil.Score.ToString(),
                             AwayTeamID = q.ScheduleInfoJlg.AwayTeamID.Value,
                             AwayTeamName = q.ScheduleInfoJlg.AwayTeamName ?? string.Empty,
                             AwayTeamNameS = q.ScheduleInfoJlg.AwayTeamNameS ?? string.Empty,
                             AwayTeamIcon = ati.TeamIcon ?? string.Empty,
                             AwayTeamRanking = arir.Ranking != null ? arir.Ranking : 0,
                             AwayTeamWin = sehei.AwayWin ?? 0,
                             AwayTeamR = atil.Score,
                             AwayTeamScore = atil.Score.ToString(),
                             Round = q.ScheduleInfoJlg.Round.Value
                         });
            }

            if (query != null)
            {
                // 予想情報を取得
                // CHSTMLとGetGameInfoForTopで同じ値を取得してしまっている。
                // TDDO IsMobileDevice廃止
                // (PC版のDBアクセス箇所をコントローラ以下に移してGetGameInfoForTopを呼ぶようにする)
                IEnumerable<GameInfoModel> expectedInfo = null;
                if (memberId > 0 && this.HttpContext.Request.Browser.IsMobileDevice)
                {
                    expectedInfo = MyPageCommon.GetGameInfoForTop(memberId, this.systemDatetimeService.TargetYear, this.systemDatetimeService.TargetMonth, 0, Constants.JLG_SPORT_ID);
                }

                var oddsService = new OddsService();

                var newQuery = query.ToList();

                foreach (var q in newQuery)
                {
                    q.GameOddsInfoModel = oddsService.GetOddsInfoByGameID(Constants.JLG_SPORT_ID, q.GameID, memberId);

                    q.GameStatus = JlgCommon.GetStatusMatch(q.GameID, memberId.ToString());

                    if (expectedInfo != null)
                    {
                        q.GameInfoModel = expectedInfo.FirstOrDefault(e => e.GameID == q.GameID && e.SportsID == Constants.JLG_SPORT_ID);

                        // todo 本来ならば、MyPageCommon.GetGameInfoForTopにて設定するべき
                        if (q.GameInfoModel != null)
                        {
                            q.GameInfoModel.GameStatus = q.GameStatus;
                        }
                    }

                    //予想している会員を取得する(ログイン会員以外)
                    ExpectInfoService expectInfoService = new ExpectInfoService(com);
                    q.BetMembers = expectInfoService.GetBetMembers(Constants.JLG_SPORT_ID, q.GameID, memberId, true);
                }

                query = newQuery.AsQueryable();
            }

            if (withScoreDetails)
            {
                //試合速報_ヘッダー情報
                if (query != null)
                {
                    var queryList = query.ToList();

                    foreach (JlgGameInfos g in queryList)
                    {
                        var report = (from rp in jlg.GameReportLG where rp.GameID == g.GameID select rp).FirstOrDefault();
                        if (report != null)
                        {
                            g.StateID = report.StateID;
                            g.StateName = report.StateName;
                            g.Half = report.Half;
                            g.HalfEndF = report.HalfEndF;
                            g.ScoreDetails = this.GetScoreDetails(g.GameID);
                        }
                        result.Add(g);
                    }

                    return result;
                }
            }
            else
            {
                return query != null ? query.ToList() : null;
            }

            return null;
        }
Пример #2
0
        public GameOddsInfoModel GetOddsInfoByGameID(int sportsId, int gameId, long memberId = 0)
        {
            var oddInfo = default(GameOddsInfoModel);

            var expectInfoService = new ExpectInfoService(this.com);

            int? betSelectedId = null; // 選択済のBET選択肢ID
            if (memberId > 0)
            {
                var expectPointInfo = expectInfoService.GetExpectPointInfo(gameId, memberId, sportsId);
                if (expectPointInfo != null) betSelectedId = expectPointInfo.BetSelectID;
            }

            oddInfo = (from et in com.ExpectTarget

                       // HomeTeam
                       join od in com.OddsInfo on et.ExpectTargetID equals od.ExpectTargetID into tmp1
                       from odh in tmp1.DefaultIfEmpty()
                       join bsm in com.BetSelectMaster on odh.BetSelectMasterID equals bsm.BetSelectMasterID into bsmtp1
                       from bsmh in bsmtp1.DefaultIfEmpty()

                       // VisitorTeam
                       join od in com.OddsInfo on et.ExpectTargetID equals od.ExpectTargetID into tmp2
                       from odv in tmp2.DefaultIfEmpty()
                       join bsm in com.BetSelectMaster on odv.BetSelectMasterID equals bsm.BetSelectMasterID into bsmtp2
                       from bsmv in bsmtp2.DefaultIfEmpty()

                       // Draw
                       join od in com.OddsInfo on et.ExpectTargetID equals od.ExpectTargetID into tmp3
                       from odd in tmp3.DefaultIfEmpty()
                       join bsm in com.BetSelectMaster on odd.BetSelectMasterID equals bsm.BetSelectMasterID into bsmtp3
                       from bsmd in bsmtp3.DefaultIfEmpty()

                       where (et.SportsID == sportsId && et.ClassClass == 4 && et.UniqueID == gameId)
                               && (odh == null || bsmh == null || bsmh.BetSelectID == 1 && odh.ClassificationType == 2)
                               && (odv == null || bsmv == null || bsmv.BetSelectID == 2 && odv.ClassificationType == 2)
                               && (odd == null || bsmd == null || bsmd.BetSelectID == 3 && odd.ClassificationType == 2)

                       select new GameOddsInfoModel
                       {
                           ExpectTargetID = et.ExpectTargetID,
                           HomeTeamOdds = (odh.Odds == null ? 0 : odh.Odds),
                           VisitorTeamOdds = (odv == null ? 0 : odv.Odds),
                           DrawOdds = (odd == null ? 0 : odd.Odds),
                           BetSelectedID = 0,
                       }).FirstOrDefault();

            if (oddInfo != null)
            {
                oddInfo.BetSelectedID = memberId > 0 ? betSelectedId : null;
            }

            if (oddInfo == null)
            {
                //Create new class to store 3 odds with value 0.
                oddInfo = new GameOddsInfoModel
                {
                    ExpectTargetID = 0,
                    HomeTeamOdds = 0,
                    VisitorTeamOdds = 0,
                    DrawOdds = 0,
                    BetSelectedID = null
                };
            }

            return oddInfo;
        }