Esempio n. 1
0
        async Task <EnrollListResponseResult> IEnrollRestService.GetAllByPage(int pageNo, int totalItemPerPage)
        {
            EnrollListResponseResult rr = new EnrollListResponseResult();
            //Items = new ObservableCollection<Enroll>();
            var url = Constants.host + "/api/enroll/getallbypage";
            var uri = new Uri(url);

            try
            {
                var postData = new List <KeyValuePair <string, string> >();
                postData.Add(new KeyValuePair <string, string>("page_no", pageNo.ToString()));
                postData.Add(new KeyValuePair <string, string>("total_item_per_page", totalItemPerPage.ToString()));
                HttpContent content = new FormUrlEncodedContent(postData);

                HttpResponseMessage response = null;
                response = await client.PostAsync(uri, content);

                if (response.IsSuccessStatusCode)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling = NullValueHandling.Ignore
                    };
                    rr = JsonConvert.DeserializeObject <EnrollListResponseResult>(result, settings);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }

            return(rr);
        }
Esempio n. 2
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            IsBusy = true;

            if (mCurrentPage == 0)
            {
                mCurrentPage = 1;
            }

            EnrollListResponseResult enrollListResponseResult = await App.EnrollManager.GetAllByPage(mCurrentPage, 10);

            BindingContext = new EnrollListViewModel(enrollListResponseResult, mCurrentPage);

            IsBusy = false;
        }