Exemplo n.º 1
0
        //get the list of results from the server
        private async void GetResults()
        {
            //build the querystring with the help of the helper
            string selectedGrade  = !(PickerGrade == null) ? PickerGrade.Items[PickerGrade.SelectedIndex] : "Grade 4";
            string selectedGender = !(PickerGender == null) ? PickerGender.Items[PickerGender.SelectedIndex] : "Male";
            string selectedSchool = !(EntrySchool == null) ? EntrySchool.Text : null;
            string selectedItem   = !(PickerSort == null) ? PickerSort.Items[PickerSort.SelectedIndex] : "Time";

            string query = resultsHelper.CreateQueryString(selectedGrade, selectedGender, selectedSchool);

            try
            {
                //see how elegant using the helper makes this?

                List <RawResult> rawresults = await resultsHelper.GetRawResults(query);

                baseResults = GetResultsHelper.ConvertAdminResults(rawresults);

                //sort results
                GetResultsHelper.SortResults(baseResults, selectedItem);

                //copy results
                CopyResults();
            }
            catch (Exception e) //pokemon exception handling
            {
                //Console.WriteLine("Caught exception " + e.Message);
                await DisplayAlert("Alert", "An unexpected error occurred while getting the list", "OK");
            }
        }
Exemplo n.º 2
0
        private void ResortResults(string selectedItem)
        {
            //sort results with helper
            GetResultsHelper.SortResults(baseResults, selectedItem);

            //copy the results to the observable list
            CopyResults();
        }
Exemplo n.º 3
0
 public LeaderboardResult(RawResult input)
 {
     result_id    = Convert.ToInt32(input.result_id);
     student_name = input.student_name;
     time         = GetResultsHelper.FormatTime(Convert.ToDecimal(input.time));
     school_name  = input.school_name;
     ranked       = Convert.ToBoolean(Convert.ToInt32(input.ranked)); //input can be 0 or 1
 }
Exemplo n.º 4
0
 public AdminResult(RawResult input)
 {
     //TODO: display formatting
     result_id    = Convert.ToInt32(input.result_id);
     student_name = input.student_name;
     date         = input.date;
     time         = GetResultsHelper.FormatTime(Convert.ToDecimal(input.time));
     school_name  = input.school_name;
     sortableDate = input.date; //this may change
     sortableTime = Convert.ToDouble(input.time);
 }
Exemplo n.º 5
0
        public LeaderboardPage()
        {
            InitializeComponent();

            client = new HttpClient();
            client.MaxResponseContentBufferSize = 256000;

            resultsHelper = new GetResultsHelper(client, App.API_URL);

            ListViewLeaderboard.ItemsSource = results;

            official = false;
        }
Exemplo n.º 6
0
        public AdminPage()
        {
            InitializeComponent();

            client = new HttpClient();
            client.MaxResponseContentBufferSize = 256000;

            resultsHelper = new GetResultsHelper(client, App.API_URL);
            deleteHelper  = new DeleteResultsHelper(client, App.API_URL);

            //test data
            //results.Add(new AdminResult {result_id = 5, student_name = "John Doe", date = "April 28 2016", time="11:11.111"});

            ListViewAdmin.ItemsSource = results;
        }
Exemplo n.º 7
0
 public PrivateResult(Result input, List <string> missedObstacles)
 {
     result_id    = Convert.ToInt32(input.result_id);
     student_name = input.student_name;
     date         = input.date;
     time         = GetResultsHelper.FormatTime(input.time);
     sortableDate = input.date;
     sortableTime = Convert.ToDouble(input.time);
     if (missedObstacles == null || missedObstacles.Count == 0)
     {
         missedObstacle = false;
     }
     else
     {
         missedObstacle       = true;
         this.missedObstacles = missedObstacles;
     }
 }
Exemplo n.º 8
0
        private async void GetResults()
        {
            //build the querystring with the help of the helper
            string selectedPeriod = !(PickerPeriod == null) ? PickerPeriod.Items[PickerPeriod.SelectedIndex] : "Daily";
            string selectedGrade  = !(PickerGrade == null) ? PickerGrade.Items[PickerGrade.SelectedIndex] : "Grade 4";
            string selectedGender = !(PickerGender == null) ? PickerGender.Items[PickerGender.SelectedIndex] : "Male";
            string selectedSchool = !(EntrySchool == null) ? EntrySchool.Text : null;
            string query          = resultsHelper.CreateQueryString(selectedPeriod, selectedGrade, selectedGender, selectedSchool, official);

            //try to get the count
            try
            {
                int count = await resultsHelper.GetCount(query);

                //Console.WriteLine(count);

                UpdateDescription(count);
            }
            catch (Exception e) //pokemon exception handling
            {
                //Console.WriteLine("Caught exception " + e.Message);
                await DisplayAlert("Alert", "An unexpected error occurred while getting the count", "OK");
            }

            //try to get the results list
            try
            {
                //see how elegant using the helper makes this?

                //Console.WriteLine(await resultsHelper.GetCount(query));

                List <RawResult> rawresults = await resultsHelper.GetRawResults(query);

                this.baseResults = GetResultsHelper.ConvertLeaderboardResults(rawresults);

                //copy results
                CopyResults();
            }
            catch (Exception e) //pokemon exception handling
            {
                //Console.WriteLine("Caught exception " + e.Message);
                await DisplayAlert("Alert", "An unexpected error occurred while getting the list", "OK");
            }
        }