public ActionResult ShowGameInfoPlayerInfo(int? gameID) { if (gameID != null) { //Get status from this session, this session must be not null. int status = (int)Session["Status"]; //Set status for viewbag to use 1 request. ViewBag.Status = status; MlbGameInformationViewModel gameInfo = new MlbGameInformationViewModel(); gameInfo.GameInSeasonSchedule = GetGameInfoCommonByGameID(gameID.Value); if (gameInfo.GameInSeasonSchedule != null) { var game = getGameInfo((int)gameID); if (game != null) { if (game.HomeScore != null) { gameInfo.HomeScore = (int)game.HomeScore; } else gameInfo.HomeScore = 0; if (game.VisitorScore != null) { gameInfo.VisitorScore = (int)game.VisitorScore; } else gameInfo.VisitorScore = 0; gameInfo.Inning = 0; } //"0=試合前、1=試合中、2=試合後 gameInfo.ListPlayerInfo = GetPlayerInfoSTByGameIDAndStatus(status, gameID.Value); if (status == 0) { gameInfo.ListPreStartingPitcher = GetTeamInfoPSPByGameID(gameID.Value); gameInfo.List5GamesInHistory = GetLastNGameInfoFromHistoryByGameID(gameID.Value, gameInfo.GameInSeasonSchedule.HomeTeamID, gameInfo.GameInSeasonSchedule.VisitorTeamID); } else if (status == 1) { gameInfo.ListGameScoreOngoing = GetGameScoreOnGoingByGameID(gameID.Value); gameInfo.ListGameText = GetAllGameTextsByGameID(gameID.Value); } else { gameInfo.ListGameText = GetAllGameTextsByGameID(gameID.Value); gameInfo.ListGameScoreEnd = GetGameScoreEndByGameID(gameID.Value); gameInfo.GameRoundComment = GetGameCommentByGameID(gameID.Value); gameInfo.ListPitcher = GetPitcherInfoInGameLiveByGameID(gameID.Value); gameInfo.ListHomerun = GetHomerunInGameLiveByGameID(gameID.Value); gameInfo.ListReliefInfoes = GetReliefInfoInGameLiveByGameID(gameID.Value); ViewBag.GameResult = GetGameResultByGameID(gameID.Value); } } else { gameInfo = null; } return PartialView("_MlbGameInfoPlayerInfo", gameInfo); } else { return PartialView("_MlbGameInfoPlayerInfo", null); } }
/// <summary> /// Method to call when loading this page. /// </summary> /// <param name="gameID">GameID</param> /// <returns>Model in this view.</returns> public ActionResult Index(int? gameID) { if (gameID != null) { //Using TempData to store gameID from request to another request. TempData["gameID"] = gameID; TempData.Keep("gameID"); //Get game status the first time. int gameStatus = MlbCommon.GetStatusMatch(gameID.ToString()); //int gameStatus = 0; //Use Session to store Status : need store long time and many request. //"0=試合前、1=試合中、2=試合後 Session["Status"] = gameStatus; @ViewBag.Status = gameStatus; MlbGameInformationViewModel gameInfo = new MlbGameInformationViewModel(); //フォローユーザーの予想 long memberId = 0; object currentUser = Session["CurrentUser"]; if (currentUser != null) memberId = Convert.ToInt64(currentUser.ToString()); if (memberId > 0) { gameInfo.FollowMembersBetToDraw = Utils.GetExpectingMembers(com, (int)gameID, memberId, 4, Constants.MLB_SPORT_ID, 1); gameInfo.FollowMembersBetToDraw = Utils.GetExpectingMembers(com, (int)gameID, memberId, 4, Constants.MLB_SPORT_ID, 3); gameInfo.FollowMembersBetToLose = Utils.GetExpectingMembers(com, (int)gameID, memberId, 4, Constants.MLB_SPORT_ID, 2); } gameInfo.GameInSeasonSchedule = GetGameInfoCommonByGameID(gameID.Value); gameInfo.ListRightContentGames = GetGameInfoRightContentByStatus(gameStatus, gameID.Value); //この試合の投稿記事 //TODO 共通メソッド待ち gameInfo.PostedInfo = Splg.Controllers.PostedController.GetRecentPosts(2, Constants.MLB_SPORT_ID, null, 1); return View(gameInfo); } return View(); }