private void displaySRPromo() { divPromo.Visible = false; PromotionInformation promo; List <CatalogItem> SRPromoOnly = new List <CatalogItem>(); Dictionary <string, SKU_V01> _AllSKUS = null; if (ShoppingCart != null && ShoppingCart.CartItems.Any()) { if (ShoppingCart.DeliveryInfo == null || string.IsNullOrEmpty(ShoppingCart.DeliveryInfo.WarehouseCode)) { return; } if (CatalogProvider.IsPreordering(ShoppingCart.CartItems, ShoppingCart.DeliveryInfo.WarehouseCode)) { return; } } else { return; } var profile = DistributorOrderingProfileProvider.GetProfile(ShoppingCart.DistributorID, ShoppingCart.DeliveryInfo.Address.Address.Country); if (ChinaPromotionProvider.IsEligibleForSRPromotion(ShoppingCart, HLConfigManager.Platform)) { var cacheKey = string.Format("GetSRPromoDetail_{0}", ShoppingCart.DistributorID); var results = HttpRuntime.Cache[cacheKey] as GetSRPromotionResponse_V01; var skuList = results.Skus.Split(',').ToArray(); if (results != null && !string.IsNullOrWhiteSpace(results.Skus)) { //if (promo.IsEligible) //{ if (skuList.Count() > 0) { if (ShoppingCart != null && ShoppingCart.CartItems.Count > 0) { if (rblFreeGiftlist.Items.Count > 0) { rblFreeGiftlist.Items.Clear(); } _AllSKUS = (ProductsBase).ProductInfoCatalog.AllSKUs; SKU_V01 sku; foreach (var t in skuList) { if (_AllSKUS.TryGetValue(t, out sku)) { if (( ShoppingCartProvider.CheckInventory(sku.CatalogItem, 1, ProductsBase.CurrentWarehouse) > 0 && (CatalogProvider.GetProductAvailability(sku, ProductsBase.CurrentWarehouse) == ProductAvailabilityType.Available))) { rblFreeGiftlist.Items.Add(new ListItem(sku.Description, t)); divPromo.Visible = true; SRPromoOnly.Add(sku.CatalogItem); } } } if (rblFreeGiftlist.Items.Count > 0) { rblFreeGiftlist.Items[0].Selected = true; } var myShoppingCart = (Page as ProductsBase).ShoppingCart; var promoInCart = myShoppingCart.CartItems.Select(c => c.SKU).Intersect(SRPromoOnly.Select(f => f.SKU)); if (promoInCart.Any()) { btnAddToCart.Enabled = false; divPromo.Visible = false; // ShoppingCart.HastakenSrPromotion = true; } else { btnAddToCart.Enabled = true; // ShoppingCart.HastakenSrPromotion = false; lblFreeGift.Text = GetLocalResourceObject("lblFreeGiftResource1.Text") as string; } if (ShoppingCart.CartItems.Count == 1) { if (promoInCart.Any()) { ShoppingCart.DeleteItemsFromCart(promoInCart.ToList(), true); } } } } } else { var itemsInBoth = ShoppingCart.CartItems.Where(x => x.IsPromo) .Select(c => c.SKU) .Intersect(skuList, StringComparer.OrdinalIgnoreCase); if (itemsInBoth.Any()) { ShoppingCart.DeleteItemsFromCart(itemsInBoth.ToList(), true); } } //} //else //{ // var itemsInBoth = // ShoppingCart.CartItems.Where(x => x.IsPromo) // .Select(c => c.SKU) // .Intersect(promo.SKUList.Select(f => f.SKU)); // if (itemsInBoth.Any()) // ShoppingCart.DeleteItemsFromCart(itemsInBoth.ToList(), true); //} } promotionPanel.Update(); }