/// <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 = NpbCommon.GetStatusMatch(gameID.ToString()); //int gameStatus = 0; //Use Session to store Status : need store long time and many request. Session["Status"] = gameStatus; @ViewBag.Status = gameStatus; NpbGameInfoViewModel gameInfo = new NpbGameInfoViewModel(); //フォローユーザーの予想 long memberId = 0; object currentUser = Session["CurrentUser"]; if (currentUser != null) memberId = Convert.ToInt64(currentUser.ToString()); if (memberId > 0) { gameInfo.FollowMembersBetToWin = Utils.GetExpectingMembers(com, (int)gameID, memberId, 4, Constants.NPB_SPORT_ID, 1); gameInfo.FollowMembersBetToDraw = Utils.GetExpectingMembers(com, (int)gameID, memberId, 4, Constants.NPB_SPORT_ID, 3); gameInfo.FollowMembersBetToLose = Utils.GetExpectingMembers(com, (int)gameID, memberId, 4, Constants.NPB_SPORT_ID, 2); } else { gameInfo.FollowMembersBetToWin = Utils.GetAllUserPrediction(com, (int)gameID, 4, Constants.NPB_SPORT_ID, 1); gameInfo.FollowMembersBetToDraw = Utils.GetAllUserPrediction(com, (int)gameID, 4, Constants.NPB_SPORT_ID, 3); gameInfo.FollowMembersBetToLose = Utils.GetAllUserPrediction(com, (int)gameID, 4, Constants.NPB_SPORT_ID, 2); } gameInfo.GameInSeasonSchedule = GetGameInfoCommonByGameID(gameID.Value); gameInfo.ListRightContentGames = GetGameInfoRightContentByDate(gameID.Value); gameInfo.PostedInfo = Splg.Controllers.PostedController.GetRecentPosts(2, Constants.NPB_SPORT_ID, null, 1); return View(gameInfo); } return View(); }
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; NpbGameInfoViewModel gameInfo = new NpbGameInfoViewModel(); gameInfo.GameInSeasonSchedule = GetGameInfoCommonByGameID(gameID.Value); if (gameInfo.GameInSeasonSchedule != null) { gameInfo.ListPlayerInfo = GetPlayerInfoSTByGameIDAndStatus(status, gameID.Value); if (status == 0) { gameInfo.ListPreStartingPitcher = GetTeamInfoPSPByGameID(gameID.Value); gameInfo.List5GamesInHistory = GetLast5GameInfoFromHistoryByGameID(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); gameInfo.ListGameTextScore = GetGameTextScoreByGameID(gameID.Value); ViewBag.GameResult = GetGameResultByGameID(gameID.Value); } } else { gameInfo = null; ViewBag.Status = -1; } return PartialView("_NpbGameInfoPlayerInfo", gameInfo); } else { return PartialView("_NpbGameInfoPlayerInfo", null); } }
/// <summary> /// 試合情報ViewModelを取得 /// </summary> /// <param name="gameId"></param> /// <param name="gameStatus"></param> /// <returns></returns> public NpbGameInfoViewModel GetViewModel(int? gameId, int gameStatus) { 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; var viewModel = new NpbGameInfoViewModel { GameInSeasonSchedule = GetGameInfoCommonByGameId(gameId.Value) }; if (viewModel.GameInSeasonSchedule != null) { viewModel.ListPlayerInfo = GetPlayerInfoStByGameIdAndStatus(gameStatus, gameId.Value); if (gameStatus == Constants.GAME_STATUS_PRE_GAME) //if (status == 0) { viewModel.ListPreStartingPitcher = GetTeamInfoPspByGameId(gameId.Value); viewModel.List5GamesInHistory = GetLast5GameInfoFromHistoryByGameId(gameId.Value, viewModel.GameInSeasonSchedule.HomeTeamID, viewModel.GameInSeasonSchedule.VisitorTeamID); } else if (gameStatus == Constants.GAME_STATUS_DURING_GAME) //else if (status == 1) { viewModel.ListGameScoreOngoing = GetGameScoreOnGoingByGameId(gameId.Value); viewModel.ListGameText = GetAllGameTextsByGameId(gameId.Value); } else { viewModel.ListGameText = GetAllGameTextsByGameId(gameId.Value); viewModel.ListGameScoreEnd = GetGameScoreEndByGameId(gameId.Value); viewModel.GameRoundComment = GetGameCommentByGameId(gameId.Value); viewModel.ListPitcher = GetPitcherInfoInGameLiveByGameId(gameId.Value); viewModel.ListHomerun = GetHomerunInGameLiveByGameId(gameId.Value); viewModel.ListReliefInfoes = GetReliefInfoInGameLiveByGameId(gameId.Value); viewModel.ListGameTextScore = GetGameTextScoreByGameId(gameId.Value); //ViewBag.GameResult = GetGameResultByGameID(gameID.Value); } } else { viewModel = null; //ViewBag.Status = -1; } return viewModel; //return PartialView("_NpbGameInfoPlayerInfo", gameInfo); } else { return null; //return PartialView("_NpbGameInfoPlayerInfo", null); } }