private async Task LoadPoints()
        {
            var client   = new WebApi();
            var response = await client.Post("Rewards/GetRequiredPoints", "");

            _list = JsonConvert.DeserializeObject <List <RequiredPoint> >(response);
            foreach (var item in _list)
            {
                if (item.RewardName.Contains("ITAS"))
                {
                    lblITASPoint.Text = item.RequiredPoints.ToString();
                }
                else if (item.RewardName.Contains("DesPad"))
                {
                    lblDesPoint.Text = item.RequiredPoints.ToString();
                }
            }
        }
Exemple #2
0
        private async Task CheckQuizzes()
        {
            var client   = new WebApi();
            var response = await client.Post($"Questions/CheckCategory?userID={_user.userID}", "");

            var questionTaken = JsonConvert.DeserializeObject <List <string> >(response);

            foreach (var item in questionTaken)
            {
                if (item == "Course")
                {
                    btnCourses.IsVisible = false;
                }
                else if (item == "TP")
                {
                    btnTP.IsVisible = false;
                }
            }
            if (btnCourses.IsVisible == false && btnTP.IsVisible == false)
            {
                lblCompleted.IsVisible = true;
            }
        }
Exemple #3
0
        private async void btnCreate_Clicked(object sender, EventArgs e)
        {
            if (entryName.Text == null || entryUserID.Text == null || entryPassword == null || entryRePassword == null)
            {
                await DisplayAlert("Create Account", "One of more field(s) are empty!", "Ok");
            }
            else if (entryPassword.Text != entryRePassword.Text)
            {
                await DisplayAlert("Create Account", "Your passwords do not match! Please check and try again!", "Ok");
            }
            else
            {
                var newUser = new User()
                {
                    userName = entryName.Text, userID = entryUserID.Text, password = entryPassword.Text, points = 0
                };
                var client   = new WebApi();
                var JsonData = JsonConvert.SerializeObject(newUser);
                var response = await client.Post("Users/Create", JsonData);

                if (response == "\"User ID has been used!\"")
                {
                    await DisplayAlert("Create Account", "User ID has been used!", "Ok");
                }
                else if (response == "\"Unable to create user account! Please contact our administrator!\"")
                {
                    await DisplayAlert("Create Account", "Unable to create user account! Please contact our administrator!", "Ok");
                }
                else
                {
                    await DisplayAlert("Create Account", "Account created successfully!", "Ok");

                    await Navigation.PopAsync();
                }
            }
        }
        private async Task LoadEvents()
        {
            var client   = new WebApi();
            var response = await client.Post("Events", "");

            _event       = JsonConvert.DeserializeObject <List <Event> >(response);
            numberOfDays = (from x in _event
                            group x by x.eventTime.Date into y
                            select y.Key).Count();

            _customViewIndex = (from x in _event
                                group x by x.eventTime.Date into y
                                select y.Key).ToList();

            var currentDay = _customViewIndex.ElementAt(dayIndex).Date;
            var customView = (from x in _event
                              where x.eventTime.Date == currentDay
                              select new { eventName = x.eventName, eventVenue = x.eventVenue, eventTime = x.eventTime.ToLocalTime().ToString("HH:mm") }).ToList();

            lvEvent.ItemsSource = customView;
            var dayString = currentDay.ToString("dd/MM/yyyy");

            lblDay.Text = $"Event of {dayString}";
        }
Exemple #5
0
        private async void btnSubmit_Clicked(object sender, EventArgs e)
        {
            var client       = new WebApi();
            var userResponse = new UserResponse()
            {
                userIDFK = _user.userID, questionIDFK = _questionSet[questionIndex].ID
            };

            if (rbAnswerOne.IsChecked)
            {
                userResponse.userAnswer = lblAnswerOne.Text;
            }
            else if (rbAnswerTwo.IsChecked)
            {
                userResponse.userAnswer = lblAnswerTwo.Text;
            }
            else if (rbAnswerThree.IsChecked)
            {
                userResponse.userAnswer = lblAnswerThree.Text;
            }
            else if (rbAnswerFour.IsChecked)
            {
                userResponse.userAnswer = lblAnswerFour.Text;
            }

            if (userResponse.userAnswer == _questionSet[questionIndex].Correct)
            {
                userResponse.isCorrect = true;
            }
            else
            {
                userResponse.isCorrect = false;
            }
            var JsonData = JsonConvert.SerializeObject(userResponse);
            var response = await client.Post("UserResponses/Create", JsonData);

            if (response == "\"Congrats! Your answer was correct!\"")
            {
                await DisplayAlert("Feedback", "Congrats! Your answer was correct!", "Ok");

                if (questionIndex == numberOfQuestion - 1)
                {
                    await DisplayAlert("End of quiz", "You have completed the last question! Redirecting you back to Quiz Menu!", "Ok");

                    await Navigation.PopAsync();
                }
                else
                {
                    questionIndex += 1;
                    ClearSelections();
                    PopulateQuestion();
                }
            }
            else if (response == "\"Your answer is incorrect!\"")
            {
                await DisplayAlert("Feedback", $"Your answer is incorrect! The correct answer is: {_questionSet[questionIndex].Correct}", "Ok");

                if (questionIndex == numberOfQuestion - 1)
                {
                    await DisplayAlert("End of quiz", "You have completed the last question! Redirecting you back to Quiz Menu!", "Ok");

                    await Navigation.PopAsync();
                }
                else
                {
                    questionIndex += 1;
                    ClearSelections();
                    PopulateQuestion();
                }
            }
            else if (response == "\"Unable to submit response!Please try again later!\"")
            {
                await DisplayAlert("Feedback", "Unable to submit response! Please try again later!", "Ok");

                await Navigation.PopAsync();
            }
        }