コード例 #1
0
        async void getData()
        {
            try
            {
                if (Application.Current.Properties.ContainsKey("user_id"))
                {
                    Config.ShowDialog();
                    var response = await ProductLogic.GetFavouriteProducts(int.Parse(Application.Current.Properties["user_id"].ToString()));

                    if (response.status == 200)
                    {
                        Config.HideDialog();
                        HomeVM.MyFavCounter = response.fav_count;
                        MessagingCenter.Send((App)Application.Current, "NavigationBar", _pageTitle);
                        if (response.data != null)
                        {
                            emptyContent.IsVisible      = false;
                            mainContent.IsVisible       = true;
                            ViewModel.FavouriteProducts = new ObservableCollection <FavouriteProductList>(response.data.ToList());
                        }
                        else
                        {
                            EmptyFavouriteProducts();
                        }
                    }
                    else
                    {
                        Config.HideDialog();
                        EmptyFavouriteProducts();
                    }
                }
                else
                {
                    EmptyFavouriteProducts();
                }
            }
            catch (Exception ex)
            {
                Config.ErrorStore("FavouritePage-getData", ex.Message);
                Config.HideDialog();
                EmptyFavouriteProducts();
                Config.ErrorSnackbarMessage(Config.ApiErrorMessage);
            }
        }