Ejemplo n.º 1
0
        /// <summary>
        /// Method that calls the funtion that checks the API health
        /// </summary>
        private async void GetApiStatus()
        {
            ProgressBarcontrol.IsIndeterminate = true;

            if (HttpHandling.GetAPIHealth())
            {
                await Task.Delay(TimeSpan.FromSeconds(2));

                Frame.Navigate(typeof(ListScreen));
            }
            else
            {
                MessageDialog message = new MessageDialog("Server health is not OK! Try again later.");

                UICommand taButton = new UICommand("Try again")
                {
                    Invoked = taButtonClick
                };
                message.Commands.Add(taButton);

                Windows.Foundation.IAsyncOperation <IUICommand> messageExploder = message.ShowAsync();
            }

            ProgressBarcontrol.IsIndeterminate = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Funtion that connects with API to retrieve a specific question
        /// </summary>
        private void RetrieveQuestion()
        {
            question = HttpHandling.RetrieveQuestion(questionIdToLoad);

            idTxt.Text              = question.Id;
            questionTxt.Text        = question.Question;
            imgSrc.Source           = new BitmapImage(new Uri(question.Image, UriKind.Absolute));
            publishTxt.Text         = question.Publish.ToString();
            choicesGrid.ItemsSource = question.Choices;
        }
Ejemplo n.º 3
0
        public ListScreen()
        {
            InitializeComponent();

            Questions = HttpHandling.GetAllQuestions();

            questionsList.ItemsSource = Questions;

            NetworkChange.NetworkAvailabilityChanged += AvailabilityChanged;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Vote button click event
 /// </summary>
 private async void voteBtn_Click(object sender, RoutedEventArgs e)
 {
     if (await HttpHandling.VoteQuestionAsync(question))
     {
         LogWriter.ShowToast("Question voted!", "Your vote has been successffully received");
     }
     else
     {
         LogWriter.ShowToast("Vote erro!", "Your vote has failed!");
     }
 }