コード例 #1
0
ファイル: MyPageCommon.cs プロジェクト: kin0428/Splg
        // Todo Serviceに移動
        /// <summary>
        /// 予想一覧向け試合情報の取得
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="target_year"></param>
        /// <param name="target_month"></param>
        /// <param name="target_date"></param>
        /// <returns></returns>
        public static IEnumerable<GameInfoModel> GetGameInfo(Int64 memberId, int target_year, int target_month, int target_date = 0, int sportsId = 0)
        {
            bool articleDispFlg;

            List<GameInfoModel> result;

            OddsService oddsService = new OddsService();

            #region 情報取得する日付の開始と終了を取得し、投稿記事のリンク表示フラグを設定する
            DateTime startDate;
            DateTime endDate;
            switch (target_date)
            {
                // 日付指定がない場合
                case 0:
                    // 当月最初の日付を取得
                    startDate = Convert.ToDateTime(target_year + "/" + target_month + "/01 00:00:00");
                    // 当月の最後の日付を取得
                    endDate = Convert.ToDateTime(target_year + "/" + target_month + "/01 23:59:59").AddMonths(1).AddDays(-1);
                    // 投稿記事を表示
                    articleDispFlg = true;
                    break;
                // 日付指定の場合
                default:
                    // 指定日の前日を取得
                    startDate = Convert.ToDateTime(target_year + "/" + target_month + "/" + target_date + " 00:00:00");
                    // 指定日を取得
                    endDate = Convert.ToDateTime(target_year + "/" + target_month + "/" + target_date + " 23:59:59");
                    // 投稿記事を表示
                    articleDispFlg = false;
                    break;
            }

            int startDateInt = startDate.ParseToInt();
            int endDateInt = endDate.ParseToInt();
            #endregion

            //NPBゲームの取得
            List<GameInfoModel> nbpGames = null;
            IEnumerable<GameInfoViewModelForNBP> npbTmp = null;

            if (sportsId == 0 || sportsId == Constants.NPB_SPORT_ID)
            {
                //予想情報の取得
                var npbExpectTargets = GetPointOfUser(memberId, Constants.NPB_SPORT_ID, startDate, endDate);

                if (npbExpectTargets != null)
                {
                    var npbGameIds = (from t in npbExpectTargets select t.GameID).Distinct().ToList();
                    NpbTopController NpbCtl = new NpbTopController();
                    npbTmp = NpbCtl.GetGameInfo(null, startDateInt, endDateInt, null, null, npbGameIds);
                }

                //TODO GetGameInfoで日付を指定するからには、NULLだった場合の対処が必要ではないか?
                if (npbTmp != null)
                {
                    nbpGames = (from g in npbTmp.ToList()
                                join e in npbExpectTargets on g.GameID equals e.GameID
                                select new GameInfoModel
                                {
                                    TargetYear = target_year,
                                    TargetMonth = target_month,
                                    StartScheduleDate = e.StartScheduleDate,
                                    SportsID = e.SportsID,
                                    ExpectTargetID = e.ExpectTargetID,
                                    GameID = g.GameID,
                                    TeamName = e.BetSelectID == 1 ? g.HomeTeamName : e.BetSelectID == 2 ? g.VisitorTeamName : "引き分け",
                                    TeamNameS = e.BetSelectID == 1 ? g.HomeTeamNameS : e.BetSelectID == 2 ? g.VisitorTeamNameS : "引き分け",
                                    Url = "/npb/game/" + g.GameID + "",
                                    UrlArticle = "/mypage/article/",
                                    HomeTeamName = g.HomeTeamName,
                                    HomeTeamID = g.HomeTeamID,
                                    HomeTeamS = g.HomeTeamNameS,
                                    VisitorTeamName = g.VisitorTeamName,
                                    VisitorTeamS = g.VisitorTeamNameS,
                                    VisitorTeamID = g.VisitorTeamID,
                                    HomeTeamIcon = g.HomeTeamIcon,
                                    VisitorTeamIcon = g.VisitorTeamIcon,
                                    HomeTeamRanking = g.HomeTeamRanking,
                                    VisitorTeamRanking = g.VisitorTeamRanking,
                                    HomeTeamWin = g.HomeTeamWin,
                                    VisitorTeamWin = g.VisitorTeamWin,
                                    HomeTeamUrl = "/npb/teams/" + g.HomeTeamID + "",
                                    VisitorTeamUrl = "/npb/teams/" + g.VisitorTeamID + "",
                                    HomeScore = Convert.ToString(g.HomeTeamScore),
                                    VisitorScore = Convert.ToString(g.VisitorTeamScore),
                                    GameDateScheduled = g.GameDate,
                                    GameTimeScheduled = g.Time,
                                    OddsInfoModel = oddsService.GetOddsInfoByGameID(Constants.NPB_SPORT_ID, g.GameID, memberId),
                                    PreForeRunnerNameSH = g.PreForeRunnerNameSH,
                                    PreForeRunnerEraH = g.PreForeRunnerEraH,
                                    PreForeRunnerNameSV = g.PreForeRunnerNameSV,
                                    PreForeRunnerEraV = g.PreForeRunnerEraV,
                                    ForeRunnerNameSH = g.ForeRunnerNameSH,
                                    ForeRunnerEraH = g.ForeRunnerEraH,
                                    ForeRunnerNameSV = g.ForeRunnerNameSV,
                                    ForeRunnerEraV = g.ForeRunnerEraV,
                                    WinLoseNameSH = g.WinLoseNameSH,
                                    WinLoseEraH = g.WinLoseEraH,
                                    WinLoseNameSV = g.WinLoseNameSV,
                                    WinLoseEraV = g.WinLoseEraV,
                                    IsWinH = g.IsWinH,
                                    IsWinV = g.IsWinV,
                                    WinLoseTextH = g.WinLoseTextH,
                                    WinLoseTextV = g.WinLoseTextV,

                                    WinLose = Convert.ToInt16(e.VorD), //勝敗1:勝ち 2:負け,
                                    BetSelectID = e.BetSelectID,
                                    SituationStatus = e.SituationStatus,
                                    ExpectPoint1 = e.ExpectPoint,
                                    StartDt = startDate

                                }).ToList();
                }
            }

            //MLBゲームの取得
            List<GameInfoModel> mlbGames = null;
            IEnumerable<GameInfoViewModelForMLB> mlbTmp = null;

            if (sportsId == 0 || sportsId == Constants.MLB_SPORT_ID)
            {
                var mlbExpectTargets = GetPointOfUser(memberId, Constants.MLB_SPORT_ID, startDate, endDate);

                if (mlbExpectTargets != null)
                {
                    MlbTopController MlbCtl = new MlbTopController();
                    var mlbGameIds = (from t in mlbExpectTargets select t.GameID).Distinct().ToList();

                    if (mlbGameIds != null)
                        mlbTmp = MlbCtl.GetGameInfo(null, startDateInt, endDateInt, null, null, mlbGameIds);
                }

                //TODO GetGameInfoで日付を指定するからには、NULLだった場合の対処が必要ではないか?
                if (mlbTmp != null)
                {
                    mlbGames = (from g in mlbTmp.ToList()
                                join e in mlbExpectTargets on g.GameID equals e.GameID
                                select new GameInfoModel
                                {
                                    TargetYear = target_year,
                                    TargetMonth = target_month,
                                    StartScheduleDate = e.StartScheduleDate,
                                    SportsID = e.SportsID,
                                    ExpectTargetID = e.ExpectTargetID,
                                    GameID = g.GameID,
                                    TeamName = e.BetSelectID == 1 ? g.HomeTeamName : e.BetSelectID == 2 ? g.VisitorTeamName : "引き分け",
                                    TeamNameS = e.BetSelectID == 1 ? g.HomeTeamNameS : e.BetSelectID == 2 ? g.VisitorTeamNameS : "引き分け",
                                    Url = "/mlb/game/" + g.GameID + "",
                                    UrlArticle = "/mypage/article/",
                                    HomeTeamName = g.HomeTeamName,
                                    HomeTeamID = g.HomeTeamID,
                                    HomeTeamS = g.HomeTeamNameS,
                                    VisitorTeamName = g.VisitorTeamName,
                                    VisitorTeamS = g.VisitorTeamNameS,
                                    VisitorTeamID = g.VisitorTeamID,
                                    HomeTeamIcon = g.HomeTeamIcon,
                                    VisitorTeamIcon = g.VisitorTeamIcon,
                                    HomeTeamRanking = g.HomeTeamRanking,
                                    VisitorTeamRanking = g.VisitorTeamRanking,
                                    HomeTeamWin = g.HomeTeamWin,
                                    VisitorTeamWin = g.VisitorTeamWin,
                                    HomeTeamUrl = "/mlb/teams/" + g.HomeTeamID + "",
                                    VisitorTeamUrl = "/mlb/teams/" + g.VisitorTeamID + "",
                                    HomeScore = Convert.ToString(g.HomeTeamScore),
                                    VisitorScore = Convert.ToString(g.VisitorTeamScore),
                                    GameDateScheduled = g.GameDate,
                                    GameTimeScheduled = g.Time,
                                    OddsInfoModel = oddsService.GetOddsInfoByGameID(Constants.MLB_SPORT_ID, g.GameID, memberId),
                                    PreForeRunnerNameSH = g.PreForeRunnerNameSH,
                                    PreForeRunnerNameSV = g.PreForeRunnerNameSV,
                                    ForeRunnerNameSH = g.ForeRunnerNameSH,
                                    ForeRunnerNameSV = g.ForeRunnerNameSV,

                                    WinLose = Convert.ToInt16(e.VorD), //勝敗1:勝ち 2:負け,
                                    BetSelectID = e.BetSelectID,
                                    SituationStatus = e.SituationStatus,
                                    ExpectPoint1 = e.ExpectPoint,
                                    StartDt = startDate

                                }).ToList();
                }
            }

            //JLGゲームの取得
            List<GameInfoModel> jlgGames = null;
            IEnumerable<JlgGameInfos> jlgTmp = null;

            if (sportsId == 0 || sportsId == Constants.JLG_SPORT_ID)
            {
                var jlgExpectTargets = GetPointOfUser(memberId, Constants.JLG_SPORT_ID, startDate, endDate);

                if (jlgExpectTargets != null)
                {
                    JlgTopController jlgCtl = new JlgTopController();
                    var jlgGameIds = (from t in jlgExpectTargets select t.GameID).Distinct().ToList();

                    if (jlgGameIds != null)
                        jlgTmp = jlgCtl.GetGameInfoByDate(null, startDateInt, endDateInt, null, null, jlgGameIds);
                }

                //TODO GetGameInfoで日付を指定するからには、NULLだった場合の対処が必要ではないか?
                if (jlgTmp != null)
                {
                    jlgGames = (from g in jlgTmp.ToList()
                                join e in jlgExpectTargets on g.GameID equals e.GameID
                                select new GameInfoModel
                                {
                                    TargetYear = target_year,
                                    TargetMonth = target_month,
                                    StartScheduleDate = e.StartScheduleDate,
                                    SportsID = e.SportsID,
                                    ExpectTargetID = e.ExpectTargetID,
                                    GameID = g.GameID,
                                    TeamName = e.BetSelectID == 1 ? g.HomeTeamName : e.BetSelectID == 2 ? g.AwayTeamName : "引き分け",
                                    TeamNameS = e.BetSelectID == 1 ? g.HomeTeamNameS : e.BetSelectID == 2 ? g.AwayTeamNameS : "引き分け",
                                    Url = "/jleague/game/" + g.GameID + "",
                                    UrlArticle = "/mypage/article/",
                                    HomeTeamName = g.HomeTeamName,
                                    HomeTeamID = Convert.ToInt32(g.HomeTeamID),
                                    HomeTeamS = g.HomeTeamNameS,
                                    VisitorTeamName = g.AwayTeamName,
                                    VisitorTeamS = g.AwayTeamNameS,
                                    VisitorTeamID = g.AwayTeamID,
                                    HomeTeamIcon = g.HomeTeamIcon,
                                    VisitorTeamIcon = g.AwayTeamIcon,
                                    HomeTeamRanking = g.HomeTeamRanking,
                                    VisitorTeamRanking = g.AwayTeamRanking,
                                    HomeTeamWin = g.HomeTeamWin,
                                    VisitorTeamWin = g.AwayTeamWin,
                                    HomeTeamUrl = "/jleague/teams/" + g.HomeTeamID + "",
                                    VisitorTeamUrl = "/jleague/teams/" + g.AwayTeamID + "",
                                    HomeScore = g.HomeTeamScore.ToString(),
                                    VisitorScore = g.AwayTeamScore.ToString(),
                                    GameDateScheduled = g.GameDate,
                                    GameTimeScheduled = g.Time,
                                    OddsInfoModel = oddsService.GetOddsInfoByGameID(Constants.JLG_SPORT_ID, g.GameID, memberId),

                                    WinLose = Convert.ToInt16(e.VorD), //勝敗1:勝ち 2:負け,
                                    BetSelectID = e.BetSelectID,
                                    SituationStatus = e.SituationStatus,
                                    ExpectPoint1 = e.ExpectPoint,
                                    StartDt = startDate
                                }).ToList();
                }
            }

            ScoreGameInfo lstScoreHome;
            ScoreGameInfo lstScoreVisitor;

            if (nbpGames != null)
            {
                foreach (var g in nbpGames)
                {
                    // 投稿記事表示フラグ
                    g.ArticleDispFlg = articleDispFlg;

                    //実際の試合日時
                    var giSS = (from gameInfo in npb.GameInfoSS
                                where gameInfo.ID == g.GameID
                                select gameInfo).FirstOrDefault();
                    if (giSS != null)
                    {
                        g.GameDateActual = giSS.GameDate;
                        g.GameTimeActual = giSS.Time;
                    }

                    //スコア
                    lstScoreHome = NpbCommon.GetTeamInfoGTSByGameIDTeamID(g.GameID, g.HomeTeamID);
                    lstScoreVisitor = NpbCommon.GetTeamInfoGTSByGameIDTeamID(g.GameID, g.VisitorTeamID);
                    if (lstScoreHome != null && lstScoreVisitor != null)
                    {
                        g.BottomTop = Utils.GetRoundName(lstScoreHome.TB);
                        g.Inning = lstScoreHome.Inning == null ? 0 : (int)lstScoreHome.Inning;
                    }

                    g.GameStatus = NpbCommon.GetStatusMatch(g.GameID, memberId.ToString());
                    //g.GameStatusSimple = NpbCommon.GetStatusMatch(g.GameID.ToString());

                    if (g.GameStatus == 6 || g.GameStatus == 7)
                    {
                        g.GameDateTime = "試合中 " + g.Inning + g.BottomTop;

                    }

                    // 試合の勝利チーム
                    var winteam = (from gi in npb.GameInfoRGI
                                   join ri in npb.GameResultInfoRGI
                               on gi.RealGameInfoRootRGIId equals ri.RealGameInfoRootRGIId
                                   where
                                   gi.GameID == g.GameID   // 試合
                                   select ri).FirstOrDefault();
                    if (winteam != null)
                    {

                        var win_teamcd = winteam.WinTeamCD;
                        if (win_teamcd == g.HomeTeamID)
                        {
                            // g.TeamName = g.HomeTeamName;
                            // g.TeamNameS = g.HomeTeamS;
                            g.WinnerTeam = 1;
                        }
                        else if (win_teamcd == g.VisitorTeamID)
                        {
                            // g.TeamName = g.VisitorTeamName;
                            // g.TeamNameS = g.VisitorTeamS;
                            g.WinnerTeam = 2;
                        }
                    }
                }
            }

            if (mlbGames != null)
            {
                foreach (var g in mlbGames)
                {
                    // 投稿記事表示フラグ
                    g.ArticleDispFlg = articleDispFlg;

                    //実際の試合日時
                    var ssi = (from ss in mlb.SeasonSchedule
                               join dg in mlb.DayGroup on ss.DayGroupId equals dg.DayGroupId
                               where ss.GameID == g.GameID
                               select new
                               {
                                   GameDate = dg.GameDateJPN,
                                   Time = ss.Time
                               }).FirstOrDefault();

                    if (ssi != null)
                    {
                        g.GameDateActual = ssi.GameDate;
                        g.GameTimeActual = ssi.Time;
                    }

                    //イニング情報とスコアを得る
                    lstScoreHome = MlbCommon.GetTeamInfoGTSByGameIDTeamIDHome(g.GameID, g.HomeTeamID);
                    lstScoreVisitor = MlbCommon.GetTeamInfoGTSByGameIDTeamIDVisitor(g.GameID, g.VisitorTeamID);

                    if (lstScoreHome != null && lstScoreVisitor != null)
                    {
                        g.BottomTop = Utils.GetRoundName(lstScoreHome.TB);
                        g.Inning = lstScoreHome.Inning == null ? 0 : (int)lstScoreHome.Inning;
                    }

                    //ゲームの状態
                    g.GameStatus = MlbCommon.GetStatusMatch(g.GameID, memberId.ToString());
                    //g.GameStatusSimple = MlbCommon.GetStatusMatch(g.GameID.ToString());

                    if (g.GameStatus == 6 || g.GameStatus == 7)
                    {
                        g.GameDateTime = "試合中";

                    }
                    // 試合の勝利チームを得る
                    // MlbTeamInfoDailyResultController.csから引用
                    var query = from realGameInfo in mlb.RealGameInfo
                                join seasonSchedule in mlb.SeasonSchedule on realGameInfo.GameID equals seasonSchedule.GameID
                                join dayGroup in mlb.DayGroup on seasonSchedule.DayGroupId equals dayGroup.DayGroupId
                                where (dayGroup.GameDateJPN.Value == g.GameDateScheduled) && (realGameInfo.GameID == g.GameID && realGameInfo.HomeTeamID == g.HomeTeamID)
                                select new
                                {
                                    WinTeamCD = realGameInfo.HomeScore > realGameInfo.VisitorScore ? realGameInfo.HomeTeamID : (realGameInfo.HomeScore < realGameInfo.VisitorScore ? realGameInfo.VisitorTeamID : null),
                                    WinTeamName = realGameInfo.HomeScore > realGameInfo.VisitorScore ? realGameInfo.HomeTeamName : (realGameInfo.HomeScore < realGameInfo.VisitorScore ? realGameInfo.VisitorTeamName : null)
                                };
                    if (query != null)
                    {
                        if (query.FirstOrDefault() != null)
                        {
                            var mlb_winteam = query.FirstOrDefault().WinTeamCD;
                            if (mlb_winteam == g.HomeTeamID)
                            {
                                //  g.TeamName = g.HomeTeamName;
                                //  g.TeamNameS = g.HomeTeamS;
                                g.WinnerTeam = 1;
                            }
                            else if (mlb_winteam == g.VisitorTeamID)
                            {
                                //  g.TeamName = g.VisitorTeamName;
                                //  g.TeamNameS = g.VisitorTeamS;
                                g.WinnerTeam = 2;
                            }
                        }
                    }

                }
            }

            if (jlgGames != null)
            {
                foreach (var g in jlgGames)
                {
                    // 投稿記事表示フラグ
                    g.ArticleDispFlg = articleDispFlg;

                    //実際の試合日時
                    lstScoreHome = JlgCommon.GetTeamInfoGTSByGameIDTeamID(g.GameID, g.HomeTeamID);
                    lstScoreVisitor = JlgCommon.GetTeamInfoGTSByGameIDTeamID(g.GameID, g.VisitorTeamID);

                    var grlg = (from gameReportLG in jlg.GameReportLG
                                where gameReportLG.GameID == g.GameID
                                select gameReportLG).FirstOrDefault();

                    if (grlg != null)
                    {
                        g.GameDateActual = grlg.GameDate;
                        g.GameTimeActual = grlg.StartTime.ToString();
                    }

                    //ゲームの状態
                    g.GameStatus = JlgCommon.GetStatusMatch(g.GameID, memberId.ToString());
                    //g.GameStatusSimple = JlgCommon.GetStatusMatch(g.GameID.ToString());

                    if (g.GameStatus == 6 || g.GameStatus == 7)
                    {
                        g.GameDateTime = "試合中";
                    }

                    // 試合の勝利チームを得る
                    int WinTeamCD = lstScoreHome.R > lstScoreVisitor.R ? g.HomeTeamID : lstScoreHome.R < lstScoreVisitor.R ? g.VisitorTeamID : 0;
                    if (WinTeamCD == g.HomeTeamID) // Home勝ち点3
                    {
                        // ホーム勝ちののBetSelectID
                        g.WinnerTeam = (int)BetConst.BetSelectID.Home;
                    }
                    else if (WinTeamCD == g.VisitorTeamID)
                    {
                        // アウェー勝ちののBetSelectID
                        g.WinnerTeam = (int)BetConst.BetSelectID.Visitor;
                    }
                    else
                    {
                        // 引き分けのBetSelectID
                        g.WinnerTeam = (int)BetConst.BetSelectID.Draw;
                    }
                }
            }

            List<GameInfoModel> allGames = new List<GameInfoModel> { };

            if (nbpGames != null)
                allGames.AddRange(nbpGames);
            if (mlbGames != null)
                allGames.AddRange(mlbGames);
            if (jlgGames != null)
                allGames.AddRange(jlgGames);

            result = allGames.OrderByDescending(s => s.usingDate).ThenByDescending(t => t.usingTime).ToList();

            return result;
        }
コード例 #2
0
ファイル: MyPageCommon.cs プロジェクト: kin0428/Splg
        /// <summary>
        /// サイトTopとXXXTopコントローラ向け試合情報の取得
        /// </summary>
        /// <param name="memberId"></param>
        /// <param name="target_year"></param>
        /// <param name="target_month"></param>
        /// <param name="target_date"></param>
        /// <returns></returns>
        public static IEnumerable<GameInfoModel> GetGameInfoForTop(Int64 memberId, int target_year, int target_month, int target_date = 0, int sportsId = 0)
        {
            #region 情報取得する日付の開始と終了を取得し、投稿記事のリンク表示フラグを設定する
            DateTime startDate;
            DateTime endDate;
            switch (target_date)
            {
                // 日付指定がない場合
                case 0:
                    // 当月最初の日付を取得
                    startDate = Convert.ToDateTime(target_year + "/" + target_month + "/01 00:00:00");
                    // 当月の最後の日付を取得
                    endDate = Convert.ToDateTime(target_year + "/" + target_month + "/01 23:59:59").AddMonths(1).AddDays(-1);
                    break;
                // 日付指定の場合
                default:
                    // 指定日の前日を取得
                    startDate = Convert.ToDateTime(target_year + "/" + target_month + "/" + target_date + " 00:00:00");
                    // 指定日を取得
                    endDate = Convert.ToDateTime(target_year + "/" + target_month + "/" + target_date + " 23:59:59");
                    break;
            }

            #endregion

            var oddsService = new OddsService();

            #region NPBゲームの取得

            List<GameInfoModel> nbpGames = null;

            if (sportsId == 0 || sportsId == Constants.NPB_SPORT_ID)
            {
                //予想情報の取得
                var npbExpectTargets = GetPointOfUser(memberId, Constants.NPB_SPORT_ID, startDate, endDate);

                nbpGames = (from e in npbExpectTargets
                            select new GameInfoModel
                            {
                                TargetYear = target_year,
                                TargetMonth = target_month,
                                StartScheduleDate = e.StartScheduleDate,
                                SportsID = e.SportsID,
                                ExpectTargetID = e.ExpectTargetID,
                                GameID = e.GameID,
                                UrlArticle = "/mypage/article/",

                                WinLose = Convert.ToInt16(e.VorD), //勝敗1:勝ち 2:負け,
                                BetSelectID = e.BetSelectID,
                                SituationStatus = e.SituationStatus,
                                ExpectPoint1 = e.ExpectPoint,
                                StartDt = startDate,
                                OddsInfoModel = oddsService.GetOddsInfoByGameID(e.SportsID, e.GameID, memberId),
                                MyPointInfoModel = ConvertToGamePointInfoModel(e)

                            }).ToList();

                if (nbpGames != null)
                {
                    foreach (var g in nbpGames)
                    {
                        // 試合の勝利チーム
                        var winteam = (from gi in npb.GameInfoRGI
                                       join ri in npb.GameResultInfoRGI
                                       on gi.RealGameInfoRootRGIId equals ri.RealGameInfoRootRGIId
                                       where gi.GameID == g.GameID   // 試合
                                       select ri).FirstOrDefault();
                        if (winteam != null)
                        {
                            g.WinTeamCd = winteam.WinTeamCD;
                        }
                    }
                }
            }

            #endregion

            #region MLBゲームの取得

            List<GameInfoModel> mlbGames = null;

            if (sportsId == 0 || sportsId == Constants.MLB_SPORT_ID)
            {
                var mlbExpectTargets = GetPointOfUser(memberId, Constants.MLB_SPORT_ID, startDate, endDate);

                mlbGames = (from e in mlbExpectTargets
                            select new GameInfoModel
                            {
                                TargetYear = target_year,
                                TargetMonth = target_month,
                                StartScheduleDate = e.StartScheduleDate,
                                SportsID = e.SportsID,
                                ExpectTargetID = e.ExpectTargetID,
                                GameID = e.GameID,
                                UrlArticle = "/mypage/article/",

                                WinLose = Convert.ToInt16(e.VorD), //勝敗1:勝ち 2:負け,
                                BetSelectID = e.BetSelectID,
                                SituationStatus = e.SituationStatus,
                                ExpectPoint1 = e.ExpectPoint,
                                StartDt = startDate,
                                OddsInfoModel = oddsService.GetOddsInfoByGameID(e.SportsID, e.GameID, memberId),
                                MyPointInfoModel = ConvertToGamePointInfoModel(e)

                            }).ToList();

                if (mlbGames != null)
                {
                    var mlbEntities = new MlbEntities();

                    foreach (var g in mlbGames)
                    {

                        // チームID,試合日を取得
                        var ss = (mlbEntities.SeasonSchedule.FirstOrDefault(s => s.GameID == g.GameID));
                        if (ss != null)
                        {
                            if (ss.HomeTeamID != null) g.HomeTeamID = (int)ss.HomeTeamID;
                            if (ss.VisitorTeamID != null) g.VisitorTeamID = (int)ss.VisitorTeamID;

                            var gg = mlbEntities.DayGroup.FirstOrDefault(x => x.DayGroupId == ss.DayGroupId);
                            if (gg != null) if (gg.GameDateJPN != null) g.GameDateScheduled = (int) gg.GameDateJPN;
                        }

                        // 試合の勝利チームを得る
                        // MlbTeamInfoDailyResultController.csから引用
                        var query = from realGameInfo in mlb.RealGameInfo
                                    join seasonSchedule in mlb.SeasonSchedule on realGameInfo.GameID equals seasonSchedule.GameID
                                    join dayGroup in mlb.DayGroup on seasonSchedule.DayGroupId equals dayGroup.DayGroupId
                                    where (dayGroup.GameDateJPN.Value == g.GameDateScheduled) && (realGameInfo.GameID == g.GameID && realGameInfo.HomeTeamID == g.HomeTeamID)
                                    select new
                                    {
                                        WinTeamCD = realGameInfo.HomeScore > realGameInfo.VisitorScore ? realGameInfo.HomeTeamID : (realGameInfo.HomeScore < realGameInfo.VisitorScore ? realGameInfo.VisitorTeamID : null),
                                        WinTeamName = realGameInfo.HomeScore > realGameInfo.VisitorScore ? realGameInfo.HomeTeamName : (realGameInfo.HomeScore < realGameInfo.VisitorScore ? realGameInfo.VisitorTeamName : null)
                                    };

                        if (query == null) continue;

                        var winteam = query.FirstOrDefault();
                        if (winteam != null)
                        {
                            if (winteam.WinTeamCD == g.HomeTeamID)
                            {
                                g.WinnerTeam = 1;
                            }
                            else if (winteam.WinTeamCD == g.VisitorTeamID)
                            {
                                g.WinnerTeam = 2;
                            }
                        }
                    }
                }
            }

            #endregion

            #region JLGゲームの取得

            List<GameInfoModel> jlgGames = null;

            if (sportsId == 0 || sportsId == Constants.JLG_SPORT_ID)
            {
                var jlgExpectTargets = GetPointOfUser(memberId, Constants.JLG_SPORT_ID, startDate, endDate);

                jlgGames = (from e in jlgExpectTargets
                            select new GameInfoModel
                            {
                                TargetYear = target_year,
                                TargetMonth = target_month,
                                StartScheduleDate = e.StartScheduleDate,
                                SportsID = e.SportsID,
                                ExpectTargetID = e.ExpectTargetID,
                                GameID = e.GameID,
                                UrlArticle = "/mypage/article/",

                                WinLose = Convert.ToInt16(e.VorD), //勝敗1:勝ち 2:負け,
                                BetSelectID = e.BetSelectID,
                                SituationStatus = e.SituationStatus,
                                ExpectPoint1 = e.ExpectPoint,
                                StartDt = startDate,
                                OddsInfoModel = oddsService.GetOddsInfoByGameID(e.SportsID, e.GameID, memberId),
                                MyPointInfoModel = ConvertToGamePointInfoModel(e)

                            }).ToList();

                if (jlgGames != null)
                {
                    var jlgEntities = new JlgEntities();

                    foreach (var g in jlgGames)
                    {
                        // チームIDを取得
                        var si = jlgEntities.ScheduleInfo.FirstOrDefault(x => x.GameID == g.GameID);
                        if (si != null)
                        {
                            if (si.HomeTeamID != null) g.HomeTeamID = (int) si.HomeTeamID;
                            if (si.AwayTeamID != null) g.VisitorTeamID = (int) si.AwayTeamID;
                        }

                        //実際の試合日時
                        var lstScoreHome = JlgCommon.GetTeamInfoGTSByGameIDTeamID(g.GameID, g.HomeTeamID);
                        var lstScoreVisitor = JlgCommon.GetTeamInfoGTSByGameIDTeamID(g.GameID, g.VisitorTeamID);

                        // 試合の勝利チームを得る
                        int winTeamCd = lstScoreHome.R > lstScoreVisitor.R ? g.HomeTeamID : lstScoreHome.R < lstScoreVisitor.R ? g.VisitorTeamID : 0;
                        if (winTeamCd == g.HomeTeamID) // Home勝ち点3
                        {
                            // ホーム勝ちののBetSelectID
                            g.WinnerTeam = (int)BetConst.BetSelectID.Home;
                        }
                        else if (winTeamCd == g.VisitorTeamID)
                        {
                            // アウェー勝ちののBetSelectID
                            g.WinnerTeam = (int)BetConst.BetSelectID.Visitor;
                        }
                        else
                        {
                            // 引き分けのBetSelectID
                            g.WinnerTeam = (int)BetConst.BetSelectID.Draw;
                        }
                    }
                }
            }

            #endregion

            var allGames = new List<GameInfoModel>();

            if (nbpGames != null)
                allGames.AddRange(nbpGames);
            if (mlbGames != null)
                allGames.AddRange(mlbGames);
            if (jlgGames != null)
                allGames.AddRange(jlgGames);

            return allGames;
        }
コード例 #3
0
ファイル: MlbTopController.cs プロジェクト: kin0428/Splg
        public IEnumerable<GameInfoViewModelForMLB> GetGameInfoByDate(int gameDate, long memberId = -1)
        {
            var query = from ss in mlb.SeasonSchedule
                        join dg in mlb.DayGroup on ss.DayGroupId equals dg.DayGroupId
                        join hti in mlb.TeamInfo on ss.HomeTeamID equals hti.TeamID
                        join vti in mlb.TeamInfo on ss.VisitorTeamID equals vti.TeamID
                        join hos in mlb.OfficialStatsMlb on ss.HomeTeamID equals hos.TeamID
                        join hdg in mlb.DivGroupMlb on hos.DivGroupMlbId equals hdg.DivGroupMlbId
                        join hlg in mlb.LeagueGroupMlb on hdg.LeagueGroupMlbId equals hlg.LeagueGroupMlbId
                        join vos in mlb.OfficialStatsMlb on ss.VisitorTeamID equals vos.TeamID
                        join vdg in mlb.DivGroupMlb on vos.DivGroupMlbId equals vdg.DivGroupMlbId
                        join vlg in mlb.LeagueGroupMlb on vdg.LeagueGroupMlbId equals vlg.LeagueGroupMlbId
                        join htim in mlb.TeamIconMlb on ss.HomeTeamID equals htim.TeamCD into htimt
                        from hi in htimt.DefaultIfEmpty()
                        join vtim in mlb.TeamIconMlb on ss.VisitorTeamID equals vtim.TeamCD into vtimt
                        from vi in vtimt.DefaultIfEmpty()
                        join rgi in mlb.RealGameInfo on ss.GameID equals rgi.GameID into regi
                        from rg in regi.DefaultIfEmpty()
                        where dg.GameDateJPN == gameDate
                         && (ss.Time.Contains("0") || ss.Time.Contains("1") || ss.Time.Contains("2") || ss.Time.Contains("3") ||
                         ss.Time.Contains("4") || ss.Time.Contains("5") || ss.Time.Contains("6") || ss.Time.Contains("7") ||
                         ss.Time.Contains("8") || ss.Time.Contains("9"))
                        orderby hti.LeagueID, hti.DivID, hti.TeamID, vti.TeamID
                        select new GameInfoViewModelForMLB
                        {
                            GameID = ss.GameID,
                            GameDate = (int)dg.GameDateJPN,
                            Time = ss.Time,
                            StadiumName = ss.StadiumName,
                            GameTypeID = (int)hti.LeagueID,
                            GameTypeName = hti.LeagueName,
                            LeagueID = (int)hti.LeagueID,
                            LeagueName = hti.LeagueName,
                            DivID = (int)hti.DivID,
                            DivName = hti.DivName,

                            HomeTeamID = ss.HomeTeamID.Value,
                            HomeTeamFullName = ss.HomeTeamFullName ?? string.Empty,
                            HomeTeamName = ss.HomeTeamName ?? string.Empty,
                            HomeTeamIcon = hi.TeamIcon,
                            HomeTeamRanking = hos.Ranking != null ? hos.Ranking : 0,
                            HomeTeamWin = hos.Win.Value != null ? hos.Win.Value : 0,
                            HomeTeamScore = rg.HomeScore,

                            VisitorTeamID = ss.VisitorTeamID.Value,
                            VisitorTeamFullName = ss.VisitorTeamFullName != null ? ss.VisitorTeamName : string.Empty,
                            VisitorTeamName = ss.VisitorTeamName ?? string.Empty,
                            VisitorTeamIcon = vi.TeamIcon,
                            VisitorTeamRanking = vos.Ranking != null ? vos.Ranking : 0,
                            VisitorTeamWin = vos.Win.Value != null ? vos.Win.Value : 0,
                            VisitorTeamScore = rg.VisitorScore,

                        };

            IEnumerable<GameInfoModel> expectedInfo = null;

            if (memberId > 0 )
            {
                expectedInfo = MyPageCommon.GetGameInfoForTop(memberId, this.systemDatetimeService.TargetYear, this.systemDatetimeService.TargetMonth, 0, Constants.MLB_SPORT_ID);
            }

            var oddsService = new OddsService();

            var newQuery = query.ToList();

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

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

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

                    if(q.GameInfoModel != null)
                        q.GameInfoModel.OddsInfoModel = q.GameOddsInfoModel;

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

                q.PreStartingPitcher = this.GetPlayerInfoSTByGameIDAndStatus(Constants.GAME_STATUS_PRE_GAME, q.GameID).FirstOrDefault();
                q.StartingPitcher = this.GetPlayerInfoSTByGameIDAndStatus(Constants.GAME_STATUS_POST_GAME, q.GameID).FirstOrDefault();
            }

            query = newQuery.AsQueryable();

            return query;
        }
コード例 #4
0
ファイル: JlgTopController.cs プロジェクト: kin0428/Splg
        ///  <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;
        }
コード例 #5
0
ファイル: MlbTopController.cs プロジェクト: kin0428/Splg
        ///  <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="startDate">StartDate.</param>
        ///  <param name="endDate">EndDate.</param>
        ///  <param name="teamId">TeamID.</param>
        ///  <param name="gameId">GameID.</param>
        ///  <param name="lstGameId">List GameID.</param>
        /// <param name="memberId">MemberID</param>
        /// <returns>List game for each condition.</returns>
        public IEnumerable<GameInfoViewModelForMLB> GetGameInfo(int? gameDate, int? startDate, int? endDate, int? teamId, int? gameId, List<int> lstGameId, long memberId = -1)
        {
            bool isValue = true;
            if (lstGameId == null)
            {
                isValue = false;
                lstGameId = new List<int>();
            }
            var query = default(IEnumerable<GameInfoViewModelForMLB>);

            query = from ss in mlb.SeasonSchedule
                        join dg in mlb.DayGroup on ss.DayGroupId equals dg.DayGroupId
                        join hti in mlb.TeamInfo on ss.HomeTeamID equals hti.TeamID
                        join vti in mlb.TeamInfo on ss.VisitorTeamID equals vti.TeamID
                        join hos in mlb.OfficialStatsMlb on ss.HomeTeamID equals hos.TeamID
                        join hdg in mlb.DivGroupMlb on hos.DivGroupMlbId equals hdg.DivGroupMlbId
                        join hlg in mlb.LeagueGroupMlb on hdg.LeagueGroupMlbId equals hlg.LeagueGroupMlbId
                        join vos in mlb.OfficialStatsMlb on ss.VisitorTeamID equals vos.TeamID
                        join vdg in mlb.DivGroupMlb on vos.DivGroupMlbId equals vdg.DivGroupMlbId
                        join vlg in mlb.LeagueGroupMlb on vdg.LeagueGroupMlbId equals vlg.LeagueGroupMlbId
                        join htim in mlb.TeamIconMlb on ss.HomeTeamID equals htim.TeamCD into htimt
                        from hi in htimt.DefaultIfEmpty()
                        join vtim in mlb.TeamIconMlb on ss.VisitorTeamID equals vtim.TeamCD into vtimt
                        from vi in vtimt.DefaultIfEmpty()
                        join rgi in mlb.RealGameInfo on ss.GameID equals rgi.GameID into regi
                        from rg in regi.DefaultIfEmpty()
                        where (gameDate == null || dg.GameDateJPN == gameDate) && (startDate == null || dg.GameDateJPN >= startDate)
                         && (endDate == null || dg.GameDateJPN <= endDate)
                         && (teamId == null || ss.HomeTeamID == teamId || ss.VisitorTeamID == teamId)
                         && (ss.GameID  == gameId || gameId == null)
                         && (ss.Time.Contains("0") || ss.Time.Contains("1") || ss.Time.Contains("2") || ss.Time.Contains("3") ||
                         ss.Time.Contains("4") || ss.Time.Contains("5") || ss.Time.Contains("6") || ss.Time.Contains("7") ||
                         ss.Time.Contains("8") || ss.Time.Contains("9") )
                          && (!isValue || lstGameId.Contains(ss.GameID))
                        orderby hti.LeagueID, hti.DivID, hti.TeamID, vti.TeamID
                        select new GameInfoViewModelForMLB
                        {
                            GameID = ss.GameID,
                            GameDate = (int)dg.GameDateJPN,
                            Time = ss.Time,
                            StadiumName = ss.StadiumName,
                            GameTypeID = (int)hti.LeagueID,
                            GameTypeName = hti.LeagueName,
                            LeagueID = (int)hti.LeagueID,
                            LeagueName = hti.LeagueName,
                            DivID = (int)hti.DivID,
                            DivName = hti.DivName,

                            HomeTeamID = ss.HomeTeamID.Value,
                            HomeTeamFullName = ss.HomeTeamFullName ?? string.Empty,
                            HomeTeamName = ss.HomeTeamName ?? string.Empty,
                            HomeTeamIcon = hi.TeamIcon,
                            HomeTeamRanking = hos.Ranking != null ? hos.Ranking : 0,
                            HomeTeamWin = hos.Win.Value != null ? hos.Win.Value : 0,
                            HomeTeamScore = rg.HomeScore,

                            VisitorTeamID = ss.VisitorTeamID.Value,
                            VisitorTeamFullName = ss.VisitorTeamFullName != null ? ss.VisitorTeamName : string.Empty,
                            VisitorTeamName = ss.VisitorTeamName ?? string.Empty,
                            VisitorTeamIcon = vi.TeamIcon,
                            VisitorTeamRanking = vos.Ranking != null ? vos.Ranking : 0,
                            VisitorTeamWin = vos.Win.Value != null ? vos.Win.Value : 0,
                            VisitorTeamScore = rg.VisitorScore,

                        };

            IEnumerable<GameInfoModel> expectedInfo = null;

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

            var oddsService = new OddsService();

            var newQuery = query.ToList();

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

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

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

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

                q.PreStartingPitcher = this.GetPlayerInfoSTByGameIDAndStatus(Constants.GAME_STATUS_PRE_GAME, q.GameID).FirstOrDefault();
                q.StartingPitcher = this.GetPlayerInfoSTByGameIDAndStatus(Constants.GAME_STATUS_POST_GAME, q.GameID).FirstOrDefault();
            }

            query = newQuery.AsQueryable();

            return query;
        }
コード例 #6
0
ファイル: JlgCommon.cs プロジェクト: kin0428/Splg
        /// <summary>
        /// 試合状況を取得
        /// </summary>
        /// <param name="gameId">試合ID</param>
        /// <param name="strMemberId">会員ID</param>
        /// <returns>
        ///  0: 試合情報なし?
        ///  1: 受付前
        ///  2: 5分前以前、ベットなし
        ///  3: 5分前以前、ベットあり
        ///  4: 5分前以降、ベットなし
        ///  5: 5分前以降、ベットあり
        ///  6: 試合中、ベットなし
        ///  7: 試合中、ベットあり
        ///  8: 試合終了、ベットなし
        ///  9: 試合終了、ベットあり
        /// 10: 試合中止
        /// </returns>
        public static int GetStatusMatch(int gameId, string strMemberId)
        {
            //Todo:判定が煩雑なので、ロジック整理の必要有り

            var memberId = !string.IsNullOrEmpty(strMemberId) ? Convert.ToInt64(strMemberId) : 0;

            if (memberId > 0)
            {
                // ポイントテーブル存在判定
                var systemDatetimeService = new SystemDatetimeService();
                var pointInfoService = new PointInfoService(new ComEntities());
                var isExist = pointInfoService.IsExistsPoint(memberId, systemDatetimeService.SystemDate);
                if (!isExist) return 1;
            }

            // BET情報を取得
            var oddsService = new OddsService();
            var oddinfo = oddsService.GetOddsInfoByGameID(Constants.JLG_SPORT_ID, gameId, memberId);
            if (oddinfo.ExpectTargetID == 0) return 1;

            var checkBet = oddinfo.BetSelectedID != null;  // BET有無

            var jlg = new JlgEntities();
            var gameInfos = (from si in jlg.ScheduleInfo //年間試合スケジュール_試合情報
                             where si.GameID == gameId
                             select new JlgGameInfoByCondidtion
                             {
                                ScheduleInfoJlg = si,
                                GameTimetoStr = si.GameTime.ToString()
                             }).First();

            int result = 0;

            if (gameInfos == null) return result;

            var gameDate = Utils.ConvertStrToDatetime(gameInfos.ScheduleInfoJlg.GameDate.ToString());

            var gameStartDateAndTime = DateTime.MaxValue; // "未定"やnullがありうる
            int time;
            if (int.TryParse(gameInfos.GameTimetoStr, out time))
            {
                var hours = Convert.ToInt32(time.ToString().Substring(0, 2));
                var minute = Convert.ToInt32(time.ToString().Substring(2, 2));

                gameStartDateAndTime = new DateTime(gameDate.Year, gameDate.Month, gameDate.Day, hours, minute, 0);
            }

            //予想可能日付閾値(今日日付基準の月末日取得)
            var expectableEnd = DateTime.Now.EndOfTheMonthWithTime();

            if (DateTime.Now < gameStartDateAndTime)
            {
                //Case 1:Can not bet
                if (gameStartDateAndTime > expectableEnd)
                {
                    return 1;                             // 1:ベット不可
                }

                DateTime limitTime = gameStartDateAndTime.AddMinutes(-5);

                if (DateTime.Now < limitTime)
                {
                    return !checkBet ? 2 : 3;         // 2:5分前以前、ベットなし  3:5分前以前、ベットあり
                }

                return !checkBet ? 4 : 5;         // 3:5分前以降、ベットなし  4:5分前以前、ベットあり
            }

            // 一試合個人スタッツ_ヘッダー情報
            var realGameInfos = from sr in jlg.StatsReportLS where sr.GameID == gameId select sr;

            if (realGameInfos != null)
            {
                if (realGameInfos.FirstOrDefault() != null)
                {
                    //空白:試合中または試合前 2=正常終了 7=サスペンデッド 9=中止(試合中)
                    string gameSetSituationCd = GetNpbGameStateID((short)realGameInfos.FirstOrDefault().SituationID);

                    if ((!string.IsNullOrEmpty(gameSetSituationCd)) && ((gameSetSituationCd == "8") ||(gameSetSituationCd == "9")))
                    {
                        return 10;
                    }

                    switch (gameSetSituationCd)
                    {
                        case "0":
                            return !checkBet ? 4 : 5;         // 4:試合前、ベットなし 5:試合前、ベットあり
                        case "1":
                            return !checkBet ? 6 : 7;         // 8:試合中、ベットなし 7:試合中、ベットあり
                        case "4":
                            return !checkBet ? 8 : 9;         // 8:試合終了、ベットなし 9:試合終了、ベットあり
                    }

                    return 10;                    // 10:試合中止
                }

                return !checkBet ? 4 : 5;         // 3:5分前以降、ベットなし  4:5分前以前、ベットあり
            }

            return !checkBet ? 4 : 5;         // 3:5分前以降、ベットなし  4:5分前以前、ベットあり
        }
コード例 #7
0
ファイル: MlbCommon.cs プロジェクト: kin0428/Splg
        /// <summary>
        /// 試合状況を取得
        /// </summary>
        /// <param name="gameId">試合ID</param>
        /// <param name="strMemberId">会員ID</param>
        /// <returns>
        ///  0: 試合情報なし?
        ///  1: 受付前
        ///  2: 5分前以前、ベットなし
        ///  3: 5分前以前、ベットあり
        ///  4: 5分前以降、ベットなし
        ///  5: 5分前以降、ベットあり
        ///  6: 試合中、ベットなし
        ///  7: 試合中、ベットあり
        ///  8: 試合終了、ベットなし
        ///  9: 試合終了、ベットあり
        /// 10: 試合中止
        /// </returns>
        public static int GetStatusMatch(int gameId, string strMemberId)
        {
            //Todo:判定が煩雑なので、ロジック整理の必要有り

            var memberId = !string.IsNullOrEmpty(strMemberId) ? Convert.ToInt64(strMemberId) : 0;

            if (memberId > 0)
            {
                // ポイントテーブル存在判定
                var systemDatetimeService = new SystemDatetimeService();
                var pointInfoService = new PointInfoService(new ComEntities());
                var isExist = pointInfoService.IsExistsPoint(memberId, systemDatetimeService.SystemDate);
                if (!isExist) return 1;
            }

            // BET情報を取得
            var oddsService = new OddsService();
            var oddinfo = oddsService.GetOddsInfoByGameID(Constants.MLB_SPORT_ID, gameId, memberId);
            if (oddinfo.ExpectTargetID == 0) return 1;

            var checkBet = oddinfo.BetSelectedID != null;  // BET有無

            var mlb = new MlbEntities();
            var gameInfos = (from ss in mlb.SeasonSchedule //年間試合スケジュール_試合情報
                             join dg in mlb.DayGroup on ss.DayGroupId equals dg.DayGroupId
                             where ss.GameID == gameId
                             select new MlbGameInfos
                             {
                                 GameDateJPN = dg.GameDateJPN,
                                 Time = ss.Time
                             }).First();

            if (gameInfos == null) return 0;

            var gameDate = Utils.ConvertStrToDatetime(gameInfos.GameDateJPN.ToString());
            var gameStartDateAndTime = DateTime.MaxValue; // 未定
            int hours = 0;
            int minute = 0;

            string time = gameInfos.Time.Trim();
            //When   time.ToString().Length <2  then  error
            //When time is 0930-> Int32.TryParse  to 900 then error because hours:90 and minute:0
            if (time.Length > 1)
                hours = Convert.ToInt32(time.Substring(0, 2));
            //When   time.ToString().Length <4  then  error
            if (time.Length > 2)
                minute = Convert.ToInt32(time.Substring(2, time.Length - 2));
            //End edit
            gameStartDateAndTime = new DateTime(gameDate.Year, gameDate.Month, gameDate.Day, hours, minute, 0);

            //予想可能日付閾値(今日日付基準の月末日取得)
            var expectableEnd = DateTime.Now.EndOfTheMonthWithTime();

            if (DateTime.MaxValue.Equals(gameStartDateAndTime) || DateTime.Now < gameStartDateAndTime)
            {
                //Case 1:Can not bet
                if (gameStartDateAndTime > expectableEnd)
                {
                    return  1;  // 1:ベット不可
                }

                var limitTime = gameStartDateAndTime.AddMinutes(-5);

                if (DateTime.Now < limitTime)
                {
                    return !checkBet ? 2 : 3;   // 2:5分前以前、ベットなし  3:5分前以前、ベットあり
                }

                return !checkBet ? 4 : 5;   // 3:5分前以降、ベットなし  4:5分前以前、ベットあり
            }

            var realGameInfos = from rgi in mlb.RealGameInfo where rgi.GameID == gameId select rgi;

            if (realGameInfos != null)
            {
                if (realGameInfos.FirstOrDefault() != null)
                {
                    //空白:試合中または試合前 2=正常終了 7=サスペンデッド 9=中止(試合中)
                    string gameSetSituationCd = GetNpbGameSetSituationCode((short)realGameInfos.FirstOrDefault().GameStateID);

                    //"0=試合前、1=試合中、2=試合後
                    int gameStatus = GetStatusMatch(gameId.ToString());

                    //int inning = realGameInfos.FirstOrDefault().Inning.HasValue ? realGameInfos.FirstOrDefault().Inning.Value : default(short);
                    if ( (!string.IsNullOrEmpty(gameSetSituationCd)) && ((gameSetSituationCd == "8") ||(gameSetSituationCd == "9")))
                    {
                        return 10;
                    }

                    if (gameSetSituationCd == "2")
                    {
                        return !checkBet ? 8 : 9;   // 8:試合終了、ベットなし 9:試合終了、ベットあり
                    }

                    if (string.IsNullOrEmpty(gameSetSituationCd) && gameStatus > 0   /*inning >= 1*/)
                    {
                        return !checkBet ? 6 : 7;   // 6:試合中、ベットなし 7:試合中、ベットあり
                    }

                    return 10;                      // 10:試合中止
                }

                return !checkBet ? 6 : 7;           // 6:試合中、ベットなし 7:試合中、ベットあり
            }

            return 0;
        }
コード例 #8
0
ファイル: NpbCommon.cs プロジェクト: kin0428/Splg
        /// <summary>
        /// 試合状況を取得
        /// </summary>
        /// <param name="gameId">試合ID</param>
        /// <param name="strMemberId">会員ID</param>
        /// <returns>
        ///  0: 試合情報なし?
        ///  1: 受付前
        ///  2: 5分前以前、ベットなし
        ///  3: 5分前以前、ベットあり
        ///  4: 5分前以降、ベットなし
        ///  5: 5分前以降、ベットあり
        ///  6: 試合中、ベットなし
        ///  7: 試合中、ベットあり
        ///  8: 試合終了、ベットなし
        ///  9: 試合終了、ベットあり
        /// 10: 試合中止
        /// </returns>
        public static int GetStatusMatch(int gameId, string strMemberId)
        {
            //Todo:判定が煩雑なので、ロジック整理の必要有り

            var memberId = !string.IsNullOrEmpty(strMemberId) ? Convert.ToInt64(strMemberId) : 0;

            if (memberId > 0)
            {
                // ポイントテーブル存在判定
                var systemDatetimeService = new SystemDatetimeService();
                var pointInfoService = new PointInfoService(new ComEntities());
                var isExist = pointInfoService.IsExistsPoint(memberId, systemDatetimeService.SystemDate);
                if (!isExist) return 1;
            }

            // BET情報を取得
            var oddsService = new OddsService();
            var oddinfo = oddsService.GetOddsInfoByGameID(Constants.NPB_SPORT_ID, gameId, memberId);
            if (oddinfo.ExpectTargetID == 0) return 1;

            var isBet = oddinfo.BetSelectedID != null; // BET有無

            var npb = new NpbEntities();

            // 年間試合スケジュール_試合情報 を取得
            var gameInfoSS = npb.GameInfoSS.FirstOrDefault(x => x.ID == gameId);

            if (gameInfoSS == null) return 0;

            // 全試合情報を取得
            string gameSetSituationCd = null; // 試合終了状況コード
            var gameInfoRGI = npb.GameInfoRGI.FirstOrDefault(x => x.GameID == gameId);
            if (gameInfoRGI != null)
            {
                gameSetSituationCd = gameInfoRGI.GameSetSituationCD;
            }

            if (!string.IsNullOrEmpty(gameSetSituationCd) && (gameSetSituationCd == "0")) // 中止(試合前)
            {
                return 10;
            }

            var gameDate = Utils.ConvertStrToDatetime(gameInfoSS.GameDate.ToString());
            var hours = Convert.ToInt32(gameInfoSS.Time.Substring(0, 2));
            var minute = Convert.ToInt32(gameInfoSS.Time.Substring(2, 2));

            var gameStartDateAndTime = new DateTime(gameDate.Year, gameDate.Month, gameDate.Day, hours, minute, 0);

            //予想可能日付閾値(今日日付基準の月末日取得)
            var expectableEnd = DateTime.Now.EndOfTheMonthWithTime();

            // 試合開始時間前
            if (DateTime.Now < gameStartDateAndTime)
            {
                //Case 1:Can not bet
                if (gameStartDateAndTime > expectableEnd)
                {
                    return 1;
                }

                //予想可能限界日付時間(Todo:5分前の定義が、マジックナンバー)
                var limitTime = gameStartDateAndTime.AddMinutes(-5);

                if (DateTime.Now < limitTime)   //締切時間前
                {
                    return !isBet ? 2 : 3;
                }

                return !isBet ? 4 : 5;  // 締切時間以降
            }

            // 試合開始時間以降
            if (gameInfoRGI == null)
            {
                return !isBet ? 4 : 5;
            }

            if (!string.IsNullOrEmpty(gameSetSituationCd) && (gameSetSituationCd == "9")) // 中止(試合中)
            {
                return 10;
            }

            if (gameSetSituationCd == "2" ||
                gameSetSituationCd == "4" ||
                gameSetSituationCd == "5" ||
                gameSetSituationCd == "8" ||
                gameSetSituationCd == "A" ||
                gameSetSituationCd == "B" ||
                gameSetSituationCd == "C" ||
                gameSetSituationCd == "D")
            {
                return !isBet ? 8 : 9;
            }

            if (!string.IsNullOrEmpty(gameSetSituationCd))
            {
                return 10;
            }

            int inning = gameInfoRGI.Inning ?? default(short);   // 現イニング

            if (inning == 0)    // 試合前
            {
                return !isBet ? 4 : 5;
            }

            if (inning >= 1)    // 試合中
            {
                return !isBet ? 6 : 7;
            }

            return 0;
        }
コード例 #9
0
ファイル: NpbTopController.cs プロジェクト: kin0428/Splg
        /// <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="startDate">StartDate.</param>
        /// <param name="endDate">EndDate.</param>
        /// <param name="teamID">TeamID.</param>
        /// <param name="gameID">GameID.</param>
        /// <param name="lstGameID">List GameID.</param>
        /// <param name="memberId">MemberID</param>
        /// <returns>List game for each condition.</returns>
        public IEnumerable<GameInfoViewModelForNBP> GetGameInfo(int? gameDate, int? startDate, int? endDate, int? teamID, int? gameID, List<int> lstGameID, long memberId = -1)
        {
            var query = default(IEnumerable<GameInfoViewModelForNBP>);
            var queryFirst = default(IQueryable<GameInfoSSByCondidtion>);
            bool isValue = true;

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

            queryFirst = from giss in npb.GameInfoSS
                         join mss in npb.MonthGroupSS on giss.MonthGroupSSId equals mss.MonthGroupSSId
                         join ss in npb.SeasonScheduleSS on mss.SeasonScheduleSSId equals ss.SeasonScheduleSSId
                         where (gameDate == null || giss.GameDate == gameDate) && (startDate == null || giss.GameDate >= startDate)
                         && (endDate == null || giss.GameDate <= endDate)
                         && (teamID == null || giss.HomeTeamID == teamID || giss.VisitorTeamID == teamID)
                         && (giss.ID == gameID || gameID == null)
                         && (!isValue || lstGameID.Contains(giss.ID))
                         select new GameInfoSSByCondidtion
                         {
                             GameInfoSSNpb = giss,
                             GameTypeID = ss.GameTypeID,
                             GameTypeName = ss.GameTypeName
                         };

            //Continue get extra info for game.
            if (queryFirst == null)
            {
                query = null;
            }
            else
            {
                query = (from q in queryFirst
                         join ti in npb.TeamIconNpb on q.GameInfoSSNpb.HomeTeamID equals ti.TeamCD
                         join ti1 in npb.TeamIconNpb on q.GameInfoSSNpb.VisitorTeamID equals ti1.TeamCD
                         join osh1 in npb.OfficialStatsHeaderNpb on q.GameTypeID equals osh1.GameAssortment
                         join os1 in npb.OfficialStatsNpb on new { p1 = q.GameInfoSSNpb.HomeTeamID.Value, p2 = osh1.OfficialStatsHeaderNpbId } equals new { p1 = os1.TeamCD, p2 = os1.OfficialStatsHeaderNpbId }
                         join osh2 in npb.OfficialStatsHeaderNpb on q.GameTypeID equals osh2.GameAssortment
                         join os2 in npb.OfficialStatsNpb on new { p1 = q.GameInfoSSNpb.VisitorTeamID.Value, p2 = osh2.OfficialStatsHeaderNpbId } equals new { p1 = os2.TeamCD, p2 = os2.OfficialStatsHeaderNpbId }
                         join tschd in npb.TeamStatsCardDifferenceHeader on q.GameTypeID equals tschd.GameAssortment
                         join tscd in npb.TeamStatsCardDifference on new { p1 = q.GameInfoSSNpb.HomeTeamID.Value, p2 = tschd.TeamStatsCardDifferenceHeaderId } equals new { p1 = tscd.TeamCD, p2 = tscd.TeamStatsCardDifferenceHeaderId }
                         join tscd1 in npb.TeamStatsCardDifferenceInfo on new { p1 = tscd.TeamStatsCardDifferenceId, p2 = q.GameInfoSSNpb.VisitorTeamID.Value } equals new { p1 = tscd1.TeamStatsCardDifferenceId, p2 = tscd1.TeamsOpponentCD } into tmp1
                         from tc1 in tmp1.DefaultIfEmpty()
                         join tscdh1 in npb.TeamStatsCardDifferenceHeader on q.GameTypeID equals tscdh1.GameAssortment
                         join tscd2 in npb.TeamStatsCardDifference on new { p1 = q.GameInfoSSNpb.VisitorTeamID.Value, p2 = tscdh1.TeamStatsCardDifferenceHeaderId } equals new { p1 = tscd2.TeamCD, p2 = tscd2.TeamStatsCardDifferenceHeaderId }
                         join tscd3 in npb.TeamStatsCardDifferenceInfo on new { p1 = tscd2.TeamStatsCardDifferenceId, p2 = q.GameInfoSSNpb.HomeTeamID.Value } equals new { p1 = tscd3.TeamStatsCardDifferenceId, p2 = tscd3.TeamsOpponentCD } into tmp2
                         from tc2 in tmp2.DefaultIfEmpty()
                         select new GameInfoViewModelForNBP
                         {
                             GameID = q.GameInfoSSNpb.ID,
                             GameDate = q.GameInfoSSNpb.GameDate,
                             Time = q.GameInfoSSNpb.Time,
                             StadiumName = q.GameInfoSSNpb.StadiumName,
                             GameTypeID = q.GameTypeID,
                             GameTypeName = q.GameTypeName,
                             HomeTeamID = q.GameInfoSSNpb.HomeTeamID.Value,
                             HomeTeamName = q.GameInfoSSNpb.HomeTeamName ?? string.Empty,
                             HomeTeamNameS = q.GameInfoSSNpb.HomeTeamNameS ?? string.Empty,
                             HomeTeamIcon = ti.TeamIcon ?? string.Empty,
                             HomeTeamRanking = os1.Ranking != null ? os1.Ranking : 0,
                             HomeTeamWin = tc1.Win.Value != null ? tc1.Win.Value : 0,
                             HomeTeamR = 0,
                             HomeTeamScore = (from rgi in npb.RealGameInfoRootRGI
                                              join girgi in npb.GameInfoRGI on rgi.RealGameInfoRootRGIId equals girgi.RealGameInfoRootRGIId
                                              join srgi in npb.ScoreRGI on rgi.RealGameInfoRootRGIId equals srgi.RealGameInfoRootRGIId
                                              where rgi.Matchday == q.GameInfoSSNpb.GameDate && girgi.GameID == q.GameInfoSSNpb.ID && q.GameInfoSSNpb.HomeTeamID == srgi.TeamCD
                                              select srgi.TotalScore).FirstOrDefault(),
                             VisitorTeamID = q.GameInfoSSNpb.VisitorTeamID.Value,
                             VisitorTeamName = q.GameInfoSSNpb.VisitorTeamName ?? string.Empty,
                             VisitorTeamNameS = q.GameInfoSSNpb.VisitorTeamNameS ?? string.Empty,
                             VisitorTeamIcon = ti1.TeamIcon ?? string.Empty,
                             VisitorTeamRanking = os2.Ranking != null ? os2.Ranking : 0,
                             VisitorTeamWin = tc2.Win.Value != null ? tc2.Win.Value : 0,
                             VisitorTeamR = 0,
                             VisitorTeamScore = (from rgi in npb.RealGameInfoRootRGI
                                                 join girgi in npb.GameInfoRGI on rgi.RealGameInfoRootRGIId equals girgi.RealGameInfoRootRGIId
                                                 join srgi in npb.ScoreRGI on rgi.RealGameInfoRootRGIId equals srgi.RealGameInfoRootRGIId
                                                 where rgi.Matchday == q.GameInfoSSNpb.GameDate && girgi.GameID == q.GameInfoSSNpb.ID && q.GameInfoSSNpb.VisitorTeamID == srgi.TeamCD
                                                 select srgi.TotalScore).FirstOrDefault(),
                             Round = q.GameInfoSSNpb.Round.Value,
                         });

            }

            if (query != null)
            {
                var newQuery = query.ToList();

                IEnumerable<GameInfoModel> exceptedInfo = null;

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

                var oddsService = new OddsService();

                foreach (var q in newQuery)
                {
                    var preStartingPichers = this.GetPlayerInfoSTByGameIDAndStatus(Constants.GAME_STATUS_PRE_GAME, q.GameID);
                    var playerInfoStarting = this.GetPlayerInfoSTByGameIDAndStatus(Constants.GAME_STATUS_DURING_GAME, q.GameID);
                    var winLosePitchers = this.GetPlayerInfoSTByGameIDAndStatus(Constants.GAME_STATUS_POST_GAME, q.GameID);

                    q.PreStartingPitcherH = preStartingPichers.FirstOrDefault(y => y.HV == 1);
                    q.PreStartingPitcherV = preStartingPichers.FirstOrDefault(y => y.HV == 2);
                    q.HomePlayerInfoStarting = playerInfoStarting.FirstOrDefault(y => y.HV == 1);
                    q.VisitorPlayerInfoStarting = playerInfoStarting.FirstOrDefault(y => y.HV == 2);
                    q.WinLosePitcherH = winLosePitchers.FirstOrDefault(y => y.HV == 1);
                    q.WinLosePitcherV = winLosePitchers.FirstOrDefault(y => y.HV == 2);

                    q.GameOddsInfoModel = oddsService.GetOddsInfoByGameID(Constants.NPB_SPORT_ID, q.GameID, memberId);

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

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

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

                query = newQuery.AsQueryable();
            }

            return query;
        }