Exemple #1
0
        private async Task InitializeAsync()
        {
            try
            {
                IsBusy = true;

                ServicesProduct servicesProduct = new ServicesProduct();
                AllProducts = await servicesProduct.ProductsAsync(SubCategories);

                dataProducts = new ObservableCollection <Product>();

                foreach (var item in AllProducts)
                {
                    dataProducts.Add(item);
                }

                IsBusy = false;
            }
            finally
            {
                if (dataProducts.Count > 0)
                {
                    isBackVisible = false;
                }
                else
                {
                    isBackVisible = true;
                }

                IsBusy = false;
            }
        }
        private async Task InitializeAsync()
        {
            try
            {
                IsBusy = true;

                ServicesProduct servicesProduct = new ServicesProduct();
                List <Category> data            = await servicesProduct.CategoriesAsync(1);

                dataCategories = new ObservableCollection <Category>();

                var categories = from x in data
                                 .Where(x => x.parent_id.Equals("0"))
                                 select x;

                subCategories = (from x in data
                                 .Where(x => x.parent_id != "0")
                                 select x).ToList();

                foreach (var item in categories)
                {
                    item.image = Constants.urlApi + item.image;
                    dataCategories.Add(item);
                }

                if (dataCategories.Count > 0)
                {
                    isCategoryVisible = true;
                }

                IsBusy = false;
            }
            finally
            {
                IsBusy = false;
            }
        }