Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         StartNewQuizGame();
     }
     else
     {
         _game = (Game) ViewState["game"];
         _questionId = (long) ViewState["questionId"];
     }
 }
Ejemplo n.º 2
0
        protected void StartNewQuizGame()
        {
            long quizId;
            _game = new Game();

            var isParsed = long.TryParse(Request.QueryString["quizId"], out quizId);
            if (isParsed)
            {
                _game.QuizId = quizId;
                _game.Score = 0;
                _questionId = 0;
                var questionWithAnswers = GameMaster.GetNextQuestionWithAnswers(_game.QuizId, _questionId);
                if (questionWithAnswers != null)
                {
                    FillInQuestionAndAnswers(questionWithAnswers);
                    _questionId = questionWithAnswers.Id;
                }
                else
                {
                    Question.Text = "The quiz is empty, please choose another quiz";
                }
            }
            else
            {
                Question.Text = "QuizID: " + quizId + " is not an valid ID";

            }
            ViewState.Add("game", _game);
            ViewState.Add("questionId", _questionId);
        }