Ejemplo n.º 1
0
        private async void OnSelectAnswer(object sender, EventArgs e)
        {
            var selectedQuestion = GetSelectedQuestion();

            Debug.Assert(selectedQuestion != null);
            Debug.Assert(string.IsNullOrEmpty(userName) == false);

            int pos = answerGroup.Children.IndexOf((Button)sender);

            if (response == null)
            {
                response = new SurveyResponse {
                    Name             = userName,
                    ResponseIndex    = pos,
                    SurveyQuestionId = selectedQuestion.Id
                };
            }
            else
            {
                Debug.Assert(response.Name == userName);
                Debug.Assert(response.SurveyQuestionId == selectedQuestion.Id);
                response.ResponseIndex = pos;
            }
            await service.AddOrUpdateSurveyResponseAsync(response);

            SetSelectedAnswer();
        }