Пример #1
0
        private async void InitializeMainPages()
        {
            string Current = "";

            UserSettings.TryGetValue("current_user", out Current);
            var tmp = await api.GetCustomersByEmail(Current);

            Currency = await api.GetCurrency();

            Customer          = tmp.First();
            CustomerName.Text = Customer.FullName;
            var Featured = await api.FeaturedProducts();

            FeaturedCount = Featured.Count();
            var FeaturedList = new List <ProductData>();
            int FeatCount    = Helper.GetSetting <int>("featured_count");
            int tmpCount     = 0;

            foreach (ProductDTO p in Featured)
            {
                if (tmpCount == FeatCount)
                {
                    break;
                }
                FeaturedList.Add(new ProductData {
                    Id = p.Id, ProductName = p.Name, Description = p.Description, Image = Helper.ConvertToBitmapImage(p.Image.First()), Value = p.Price.ToString("0") + " " + Currency
                });
                tmpCount++;
            }
            FeaturedProducts.ItemsSource = FeaturedList;
            var BestsellersA = await api.GetBestsellerByAmount();

            var BestsellersQ = await api.GetBestsellerByQuantity();

            var Bests     = new List <ProductData>();
            var BestCount = Helper.GetSetting <int>("bestsellers_count") / 2;

            for (int i = 0; i < BestCount; i++)
            {
                if (i < BestsellersA.Count())
                {
                    Bests.Add(new ProductData {
                        Id = BestsellersA[i].Product.Id, ProductName = BestsellersA[i].Product.Name, Value = BestsellersA[i].Product.Price.ToString("0.#") + " " + Currency, Image = Helper.ConvertToBitmapImage(BestsellersA[i].Product.Image.First())
                    });
                }
                if (i < BestsellersQ.Count())
                {
                    Bests.Add(new ProductData {
                        Id = BestsellersQ[i].Product.Id, ProductName = BestsellersQ[i].Product.Name, Value = BestsellersQ[i].Product.Price.ToString("0.#") + " " + Currency, Image = Helper.ConvertToBitmapImage(BestsellersQ[i].Product.Image.First())
                    });
                }
            }
            BestsellersList.ItemsSource = Bests;
            var Categories = await api.GetMainCategories();

            var CategoriesList = new List <CategoryData>();

            foreach (CategoryDTO c in Categories)
            {
                CategoriesList.Add(new CategoryData {
                    Id = c.Id, Name = c.Name, Image = Helper.ConvertToBitmapImage(c.Image)
                });
            }
            CategoriesListbox.ItemsSource = CategoriesList;
            HideLoading();
        }