コード例 #1
0
        private void BindPromotions()
        {
            var variationContent = CurrentData as VariationContent;

            if (variationContent == null)
            {
                variationContent = GetVariants <VariationContent>().FirstOrDefault(FilterAction);
            }

            Visible = false;
            if (variationContent == null)
            {
                return;
            }

            // We have to load an entry to be able to get promotions.
            var entrySku        = variationContent.LoadEntry();
            var currentMarketId = CurrentMarket.GetCurrentMarket().MarketId;

            if (!entrySku.IsAvailableInMarket(currentMarketId))
            {
                return;
            }

            Promotions.Text = String.Empty;

            var promotions = entrySku.GetPromotions();

            if (!promotions.PromotionRecords.Any())
            {
                return;
            }

            Visible = true;
            PromotionsHolder.Visible = true;

            var marketService = Locate.MarketService();

            foreach (var record in promotions.PromotionRecords)
            {
                var promotionName = record.PromotionItem.DataRow.GetPromotionLanguageRows().FirstOrDefault(x => x.LanguageCode == marketService.GetMarket(MarketId.Default).DefaultLanguage.ToString()) != null?
                                    record.PromotionItem.DataRow.GetPromotionLanguageRows().FirstOrDefault(x => x.LanguageCode == marketService.GetMarket(MarketId.Default).DefaultLanguage.ToString()).DisplayName:
                                    record.PromotionItem.DataRow.Name;

                Promotions.Text += string.Format("Promotion Name: {0} <br/>", promotionName);
                Promotions.Text += string.Format("Amount Off: {0}{1}<br/>", record.PromotionReward.AmountOff.ToString(), record.PromotionReward.AmountType == "Percentage" ? "%" : "");
            }
        }