protected void SubmitButton_OnClick(object sender, EventArgs e) { if (IsValid) { using (var controller = new QuestionController()) { var questionId = controller.AskQuestion(TitleTextBox.Text, BodyTextBox.Text); if (questionId != -1) { Response.Redirect($"~/QuestionDetail.aspx?QuestionID={questionId}"); } else { AlertDiv.Visible = true; } } } }
public void set_state(int state) { if (state == current_state) { return; } if (MyConst.ACTION_STATE_UNKNOWN == current_state) { if (MyConst.ACTION_STATE_ASK_QUESTION == state) { m_master_animator.SetInteger("action", MyConst.ACTION_STATE_ASK_QUESTION); m_question_controller.AskQuestion(); m_before_event_callback_enable = true; m_start_tick = System.DateTime.Now; } } else if (MyConst.ACTION_STATE_ASK_QUESTION == current_state) { if (MyConst.ACTION_STATE_WAIT_QUESTION == state) { m_master_animator.SetInteger("action", MyConst.ACTION_STATE_WAIT_QUESTION); // m_before_event_callback_enable = true; // m_start_tick = System.DateTime.Now; } } else if (MyConst.ACTION_STATE_WAIT_QUESTION == current_state) { if (MyConst.ACTION_STATE_REVIEW_ANSWER == state || MyConst.ACTION_STATE_MASTER_AGREE == state || MyConst.ACTION_STATE_MASTER_DISAGREE == state) { m_master_animator.SetInteger("action", state); m_stopwatch.StopTheWatch(); m_before_event_callback_enable = true; m_start_tick = System.DateTime.Now; } if (MyConst.ACTION_STATE_ANSWER_TIMEOUT == state) { m_master_animator.SetInteger("action", MyConst.ACTION_STATE_REVIEW_ANSWER); m_stopwatch.StopTheWatch(); incr_score(-10); m_before_event_callback_enable = true; m_start_tick = System.DateTime.Now; } } else if (MyConst.ACTION_STATE_REVIEW_ANSWER == current_state) { if (MyConst.ACTION_STATE_ASK_QUESTION == state) { m_master_animator.SetInteger("action", state); m_question_controller.AskQuestion(); m_before_event_callback_enable = true; m_start_tick = System.DateTime.Now; } } else if (MyConst.ACTION_STATE_MASTER_AGREE == current_state) { if (MyConst.ACTION_STATE_ASK_QUESTION == state) { m_master_animator.SetInteger("action", state); m_question_controller.AskQuestion(); m_before_event_callback_enable = true; m_start_tick = System.DateTime.Now; } } else if (MyConst.ACTION_STATE_MASTER_DISAGREE == current_state) { if (MyConst.ACTION_STATE_ASK_QUESTION == state) { m_master_animator.SetInteger("action", state); m_question_controller.AskQuestion(); m_before_event_callback_enable = true; m_start_tick = System.DateTime.Now; } } else if (MyConst.ACTION_STATE_ANSWER_TIMEOUT == current_state) { if (MyConst.ACTION_STATE_ASK_QUESTION == state) { m_master_animator.SetInteger("action", state); m_question_controller.AskQuestion(); m_before_event_callback_enable = true; m_start_tick = System.DateTime.Now; } } current_state = state; }