Пример #1
0
        private async Task LoadWhiteWines()
        {
            if (whitewineModelList.Count == 0 || WhiteWineRefreshedNext < DateTime.Now)
            {
                WhiteWineRefreshedNext = DateTime.Now.AddMinutes(40);

                var categories = await DealData.GetDealByWineTypeAsync(false);

                whitewineModelList = new List <DealsInCategoryViewModel>();
                DealsInCategoryViewModel cvm;
                foreach (var item in categories)
                {
                    if (!string.IsNullOrEmpty(item.DealId))
                    {
                        cvm = new DealsInCategoryViewModel();

                        cvm.Title     = item.Title;
                        cvm.Price     = string.Format("{0:C}", item.Price);
                        cvm.DealId    = item.DealId;
                        cvm.WineColor = "#FFDCE08C";

                        whitewineModelList.Add(cvm);
                    }
                }

                WhiteWineDealsGridView.ItemsSource = whitewineModelList;

                foreach (var item in whitewineModelList)
                {
                    var images = await DealImageData.GetDealImagesAsync(item.DealId, "250x250");

                    item.ImageUrls = images.Select(x => x.ImageUrl).First();
                }
            }
        }
Пример #2
0
        private async Task LoadViewModel()
        {
            if (!vm.Keys.Contains(CategoryIdParam))
            {
                var categories = await DealData.GetDealsAsync(CategoryIdParam);

                viewModel = new List <DealsInCategoryViewModel>();
                DealsInCategoryViewModel cvm;
                foreach (var item in categories)
                {
                    if (!string.IsNullOrEmpty(item.DealId))
                    {
                        cvm = new DealsInCategoryViewModel();

                        if (item.Redwine)
                        {
                            cvm.WineColor = "#FF660E00";
                        }
                        else
                        {
                            cvm.WineColor = "#FFDCE08C";
                        }

                        cvm.Title  = item.Title;
                        cvm.Price  = string.Format("{0:C}", item.Price);
                        cvm.DealId = item.DealId;

                        viewModel.Add(cvm);
                    }
                }

                vm.Add(CategoryIdParam, viewModel);

                var source = vm.Where(e => e.Key == CategoryIdParam).Select(e => e.Value).Single();
                itemsViewSource.Source = source;

                foreach (var item in viewModel)
                {
                    var images = await DealImageData.GetDealImagesAsync(item.DealId, "250x250");

                    item.ImageUrls = images.Select(x => x.ImageUrl).First();
                }
            }
            else
            {
                var source = vm.Where(e => e.Key == CategoryIdParam).Select(e => e.Value).Single();
                itemsViewSource.Source = source;
            }
        }