Пример #1
0
        /*
         * when user submit one of 4 answer the function called
         */
        private void SubmitAnswer(object sender, RoutedEventArgs e)
        {
            var answer = sender as Button;
            SubmitAnswerRequest submitAnswerRequest = new SubmitAnswerRequest(helper.get_answer_id(answer.Name));
            var    json     = new JavaScriptSerializer().Serialize(submitAnswerRequest);
            string request  = Constants.SUBMIT_ANSWER_ID.ToString() + json.Length.ToString() + json;
            string response = helper.SendAndRecive(request);
            SubmitAnswerResponse submitAnswerResponse = new JavaScriptSerializer().Deserialize <SubmitAnswerResponse>(response);

            if (submitAnswerResponse.is_right)
            {
                answer.Foreground = Brushes.Green;
            }
            else
            {
                answer.Foreground = Brushes.Red;
            }
            set_question();
        }