Пример #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;
        }
Пример #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;
        }
Пример #3
0
        public ListScreen()
        {
            InitializeComponent();

            Questions = HttpHandling.GetAllQuestions();

            questionsList.ItemsSource = Questions;

            NetworkChange.NetworkAvailabilityChanged += AvailabilityChanged;
        }
Пример #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!");
     }
 }