private async void ApplyFilter(object sender, EventArgs e) { ProductListProperty.IsLoading = true; try { if (HolderFilter.IsVisible) { ShowFilter(null, null); } ProductListProperty.PropertiesFilter.UserId = AppStatics.UserID != -1 ? AppStatics.UserID : 0; var responseProductsFiltered = await new Services.HttpExtension <List <BLL.M.Mobile.Product> >().Post("Category/GetFullSearchCategories", ProductListProperty.PropertiesFilter); if (responseProductsFiltered != null) { if (responseProductsFiltered.Count == 0) { ProductListProperty.PropertiesFilter.CurrentPage--; } Device.BeginInvokeOnMainThread(() => { ButNext.IsVisible = responseProductsFiltered?.Count == ProductListProperty.PropertiesFilter.PageSize; ButPrevious.IsVisible = ProductListProperty.PropertiesFilter.CurrentPage > 0; }); if (responseProductsFiltered.Count > 0) { ProductListProperty.Products = responseProductsFiltered == null ? null : new ObservableCollection <BLL.M.Mobile.Product>(responseProductsFiltered); Device.BeginInvokeOnMainThread(() => ListViewProduct.ScrollTo(ProductListProperty.Products.FirstOrDefault(), ScrollToPosition.Start, false)); } else { await DisplayAlert("", MultiLanguage.MLResource.NoMoreItem, MultiLanguage.MLResource.Ok); } } else { ProductListProperty.PropertiesFilter.CurrentPage--; } } catch (Exception ex) { if (Xamarin.Essentials.Connectivity.NetworkAccess != Xamarin.Essentials.NetworkAccess.Internet) { await App._nav.DisplayAlert(MultiLanguage.MLResource.InternetConnectionTitle, MultiLanguage.MLResource.InternetConnectionMessage, MultiLanguage.MLResource.Ok); } else #if DEBUG { await App._nav.DisplayAlert(MultiLanguage.MLResource.Error, ex.ToString(), MultiLanguage.MLResource.Ok); } #elif RELEASE { await App._nav.DisplayAlert(MultiLanguage.MLResource.Error, MultiLanguage.MLResource.FailedMessage, MultiLanguage.MLResource.Ok); } #endif } ProductListProperty.IsLoading = false; }
private void PreviousListProduct(object sender, EventArgs e) { ListViewProduct.ScrollTo(ListViewProduct.Header, ScrollToPosition.Start, false); ProductListProperty.PropertiesFilter.CurrentPage--; ApplyFilter(null, null); }