protected async Task RefreshAllocations() { MyDB DB = new MyDB(); //if (CrossConnectivity.Current.IsConnected) //{ try { App_activity_indicator.IsVisible = true; App_activity_indicator.IsRunning = true; string webaddress = Libraries.MobileConfig.GetWebAddress(Application.Current.Properties["campus"].ToString()) + string.Format("DataFinder.aspx?dataFormat=mycourses&empcode={0}&acad={1}&sem={2}", Application.Current.Properties["userno"], txt_year.SelectedItem.ToString(), txt_semester.SelectedItem.ToString().Substring(9, 1)); _client.Timeout = TimeSpan.Parse("00:00:15"); var content = await _client.GetStringAsync(webaddress); var n = JsonConvert.DeserializeObject <List <Model.CourseAllocationModel> >(content); List <Model.CourseAllocationModel> TT_data = new List <Model.CourseAllocationModel>(n); if (TT_data.Count > 0) { DB.resetCourseAllocations(); DB.AddCourseAllocation(Application.Current.Properties["userno"].ToString(), content); } else { DB.resetCourseAllocations(); lv_timetable.ItemsSource = null; } App_activity_indicator.IsVisible = false; App_activity_indicator.IsRunning = false; } catch (Exception ex) { //await DisplayAlert("Error!", "" + ex.Message, "OK"); // DB.resetCourseAllocations(); lv_timetable.ItemsSource = null; App_activity_indicator.IsVisible = false; App_activity_indicator.IsRunning = false; } //} //else //{ // await DisplayAlert("Warning", "No Internet Connection", "OK"); //} var list = JsonConvert.DeserializeObject <List <Model.CourseAllocationModel> >(DB.GetMyCourseALlocations(Application.Current.Properties["userno"].ToString())); List <Model.CourseAllocationModel> display_data = new List <Model.CourseAllocationModel>(list); display_data = display_data.Where(c => c.sem == int.Parse(txt_semester.SelectedItem.ToString().Substring(9, 1)) && c.acad_year == txt_year.SelectedItem.ToString()).ToList(); lv_timetable.ItemsSource = display_data; }