public ActionResult Results() { if (User.Role.IsAuthor) { return(this.RedirectToAction <GamesController>(c => c.CurrentState(User.Game.Id))); } TeamGameboardViewModel model = TeamGameboardViewModel.CreateTeamGameboardViewModel(); model.GameResults = gameService.GetGameResults(User.Team.Game.Id).Select("", "tasks desc, bonus desc, time asc"); Team team = teamRepository.Get(User.Team.Id); model.TeamGameState = team.TeamGameState; if (!model.TeamGameState.GameDoneTime.HasValue) { return(this.RedirectToAction(c => c.Show())); } if (model.TeamGameState == null) { return(this.RedirectToAction <HomeController>(c => c.Index())); } return(View(model)); }
public ActionResult Show() { if (User.Role.IsAuthor) { return(this.RedirectToAction <GamesController>(c => c.CurrentState(User.Game.Id))); } Team team = teamRepository.Get(User.Team.Id); TeamGameboardViewModel viewModel = TeamGameboardViewModel.CreateTeamGameboardViewModel(); viewModel.ErrorMessage = Message; if (team.Game == null) { viewModel.Message = "Для Вас нет активной игры."; } else if (team.Game.GameState == GameStates.Finished) { viewModel.Message = "Игра закончена."; return(RedirectToAction("Results")); } else if (team.Game.GameState == GameStates.Planned) { viewModel.Message = String.Format("Игра запланирована на {0}", team.Game.GameDate.ToShortDateString()); } else if (team.Game.GameState == GameStates.Startup || (team.Game.GameState == GameStates.Started && team.Game.GameDate > DateTime.Now)) { viewModel.Message = String.Format("Игра начнется в {0}", team.TeamGameState.Game.GameDate.TimeOfDay); } else if (team.TeamGameState.GameDoneTime != null) { viewModel.Message = "Игра закончена. Для Вас пока больше нет заданий. Возможно Вы выполнили все задания :-)"; return(RedirectToAction("Results")); } else { viewModel.TaskNo = team.TeamGameState.AcceptedTasks.Count; viewModel.TeamGameState = team.TeamGameState; viewModel.ActiveTaskState = team.TeamGameState.ActiveTaskState; if (viewModel.ActiveTaskState != null && viewModel.ActiveTaskState.Task.TaskType == TaskTypes.RussianRoulette) { viewModel.SuggestTips = gameService.GetSuggestTips(viewModel.ActiveTaskState, DateTime.Now); if (viewModel.SuggestTips != null) { viewModel.SuggestMessage = viewModel.SuggestTips.Count() == 3 ? "У вас есть две подсказки из трёх. Выберите одну из них:" : "У вас осталась последняя подсказка! Выберите одну из двух:"; } } } viewModel.TeamName = team.Name; return(View(viewModel)); }