Esempio n. 1
0
 public Dictionary <string, bool> GetEventsByDistributor()
 {
     if (!string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.EventId))
     {
         var distributorProfileModel = (MembershipUser <DistributorProfileModel>)Membership.GetUser();
         var cacheKey          = string.Format("distributorEvents_{0}", distributorProfileModel.Value.Id);
         var distributorEvents = HttpRuntime.Cache[cacheKey] as Dictionary <string, bool>;
         if (distributorEvents == null || distributorEvents.Count == 0)
         {
             var eventIds = HLConfigManager.Configurations.DOConfiguration.EventId.Split('|');
             foreach (var id in eventIds)
             {
                 var eventId = 0;
                 if (int.TryParse(id, out eventId) && eventId > 0)
                 {
                     var dsWithTicket = false;
                     var isQualified  = DistributorOrderingProfileProvider.IsEventQualified(eventId, "ru-RU", out dsWithTicket);
                     if (distributorEvents == null)
                     {
                         distributorEvents = new Dictionary <string, bool>();
                     }
                     distributorEvents.Add(id, isQualified && dsWithTicket);
                 }
             }
             HttpRuntime.Cache.Insert(cacheKey, distributorEvents, null, DateTime.Now.AddMinutes(RU_SHIPPINGINFO_CACHE_MINUTES),
                                      Cache.NoSlidingExpiration, CacheItemPriority.Normal, null);
         }
         return(distributorEvents);
     }
     return(null);
 }
Esempio n. 2
0
        public override List <DeliveryOption> GetDeliveryOptions(DeliveryOptionType type, ShippingAddress_V01 address)
        {
            if (type == DeliveryOptionType.Pickup)
            {
                var baseList = base.GetDeliveryOptions(type, address);

                // US 262457: Check for Prague Extravaganza pickup location
                var eventId = 0;
                if (int.TryParse(HLConfigManager.Configurations.DOConfiguration.EventId, out eventId) && eventId > 0 && baseList != null)
                {
                    if (!string.IsNullOrEmpty(HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse))
                    {
                        var memberWithTicket = false;
                        var memberQualified  = DistributorOrderingProfileProvider.IsEventQualified(eventId, "cs-CZ", out memberWithTicket);
                        if (!memberQualified || !memberWithTicket)
                        {
                            baseList = baseList.Where(x => x.Description != HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse).ToList();
                        }
                    }
                }

                return(baseList);
            }
            return(base.GetDeliveryOptions(type, address));
        }
Esempio n. 3
0
        private ShoppingCartRuleResult CheckQualifiedEventSkus(ShoppingCart_V01 shoppingCart, ShoppingCartRuleResult ruleResult)
        {
            if (shoppingCart != null)
            {
                List <string> ConfigSKUList = HLConfigManager.Configurations.DOConfiguration.SkuForCurrentEvent.Split(',').ToList();
                var           SKUList       = GetExtravaganza2017Skus();
                if (SKUList != null && ConfigSKUList != null)
                {
                    SKUList.AddRange(from s in ConfigSKUList
                                     where !SKUList.Contains(s)
                                     select s);
                }

                var cart = shoppingCart as MyHLShoppingCart;

                if (SKUList.Any() && SKUList.Contains(cart.CurrentItems[0].SKU))
                {
                    bool memberWithTicket;
                    var  memberQualified = DistributorOrderingProfileProvider.IsEventQualified(EventId, Locale, out memberWithTicket);
                    if (!memberQualified)
                    {
                        var message = "SKUNotAvailableForNonQualified";
                        var globalResourceObject = PlatformResources.GetGlobalResourceString("ErrorMessage", message);
                        if (!string.IsNullOrEmpty(globalResourceObject))
                        {
                            message = string.Format(globalResourceObject.ToString(), cart.CurrentItems[0].SKU);
                        }
                        ruleResult.AddMessage(message);
                        ruleResult.Result = RulesResult.Failure;
                    }
                }
            }
            return(ruleResult);
        }
Esempio n. 4
0
        public ShoppingCartRuleResult checkForConfigBlockedSKU(ShoppingCart_V01 shoppingCart,
                                                               ShoppingCartRuleResult ruleResult)
        {
            if (EventId > 0 && !DistributorOrderingProfileProvider.IsEventQualified(EventId, shoppingCart.Locale))
            {
                var           cart       = shoppingCart as MyHLShoppingCart;
                List <string> listToHide =
                    HLConfigManager.Configurations.DOConfiguration.SkuToNoDisplayForNonQualifyMembers.Split(',').ToList();
                if (cart != null && listToHide.Contains(cart.CurrentItems[0].SKU))
                {
                    var message = "SKUNotAvailable";
                    var globalResourceObject =
                        HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform),
                                                            "SKUNotAvailable");
                    if (globalResourceObject != null)
                    {
                        message = string.Format(globalResourceObject.ToString(), shoppingCart.CurrentItems[0].SKU);
                    }

                    ruleResult.AddMessage(message);
                    ruleResult.Result = RulesResult.Failure;
                }
            }

            return(ruleResult);
        }
        public void RemoveUnauthorizedDeliveryOptions(List <DeliveryOption> devliveryOptions, string locale)
        {
            var isAuthorized = DistributorOrderingProfileProvider.IsEventQualified(Honors2016EventId, locale);

            if (devliveryOptions.Any(o => o.WarehouseCode == HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse) &&
                !isAuthorized)
            {
                devliveryOptions.RemoveAll(o => o.WarehouseCode == HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse);
            }
        }
Esempio n. 6
0
        private void SetPredefinedPickUpOption()
        {
            var predefinedValue =
                HLConfigManager.Configurations.PickupOrDeliveryConfiguration.PredefinedPickUpLocationName;

            if (HLConfigManager.Configurations.DOConfiguration.IsEventInProgress &&
                HLConfigManager.Configurations.PickupOrDeliveryConfiguration.HasPredefinedPickUp &&
                !_pickupRrefList.Any(p => p.PickupLocationNickname.Equals(predefinedValue)))
            {
                if (DistributorOrderingProfileProvider.IsEventQualified(Honors2016EventId, Locale))
                {
                    //Get the Id searching by zip code
                    var devileryOptionsForEvent = ProductsBase.GetShippingProvider()
                                                  .GetDeliveryOptions(DeliveryOptionType.Pickup, new ShippingAddress_V01()
                    {
                        Address = new Address_V01()
                        {
                            PostalCode = HLConfigManager.Configurations.PickupOrDeliveryConfiguration.PredefinedPickUpLocationZipCode.ToString()
                        }
                    });

                    var pickUpLocationId = devileryOptionsForEvent.SingleOrDefault(p => p.WarehouseCode == HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse);
                    if (pickUpLocationId != null && pickUpLocationId.Id > 0)
                    {
                        ProductsBase.GetShippingProvider()
                        .SavePickupLocationsPreferences
                        (
                            DistributorID,
                            true,
                            pickUpLocationId.Id,
                            predefinedValue,
                            predefinedValue,
                            "MX",
                            false);
                        reload();
                    }
                }
            }
        }
 private ShoppingCartRuleResult CheckHonors2016Skus(ShoppingCart_V01 shoppingCart,
                                                    ShoppingCartRuleResult ruleResult)
 {
     if (shoppingCart != null)
     {
         var honors2016Skus = GetHonors2016Skus();
         var cart           = shoppingCart as MyHLShoppingCart;
         if (honors2016Skus.Contains(shoppingCart.CurrentItems[0].SKU))
         {
             if (!DistributorOrderingProfileProvider.IsEventQualified(Honors2016EventId, Locale))
             {
                 var message = "SKUNotAvailable";
                 var globalResourceObject =
                     HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform),
                                                         "SKUNotAvailable");
                 if (globalResourceObject != null)
                 {
                     message = string.Format(globalResourceObject.ToString(), shoppingCart.CurrentItems[0].SKU);
                 }
                 ruleResult.AddMessage(message);
                 ruleResult.Result = RulesResult.Failure;
             }
             else
             {
                 if (cart != null && cart.DeliveryInfo != null &&
                     cart.DeliveryInfo.Option != DeliveryOptionType.Pickup &&
                     cart.DeliveryInfo.WarehouseCode != HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse)
                 {
                     var message = "SKUNotAvailable";
                     var globalResourceObject =
                         HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform),
                                                             "SKUNotAvailable");
                     if (globalResourceObject != null)
                     {
                         message = string.Format(globalResourceObject.ToString(), shoppingCart.CurrentItems[0].SKU);
                     }
                     ruleResult.AddMessage(message);
                     ruleResult.Result = RulesResult.Failure;
                 }
                 else if (cart != null && cart.DeliveryInfo != null &&
                          cart.DeliveryInfo.Option == DeliveryOptionType.Pickup &&
                          cart.DeliveryInfo.WarehouseCode == HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse &&
                          shoppingCart.CartItems != null &&
                          shoppingCart.CartItems.Any(i => !honors2016Skus.Contains(i.SKU) && !APFDueProvider.IsAPFSku(i.SKU)))
                 {
                     var message = "StandaloneSku";
                     var globalResourceObject =
                         HttpContext.GetGlobalResourceObject(
                             string.Format("{0}_Rules", HLConfigManager.Platform),
                             "StandaloneSku");
                     if (globalResourceObject != null)
                     {
                         message = string.Format(globalResourceObject.ToString(),
                                                 shoppingCart.CurrentItems[0].SKU);
                     }
                     ruleResult.AddMessage(message);
                     ruleResult.Result = RulesResult.Failure;
                 }
                 else if (cart != null && cart.DeliveryInfo != null &&
                          cart.DeliveryInfo.Option == DeliveryOptionType.Pickup &&
                          cart.DeliveryInfo.WarehouseCode != HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse &&
                          shoppingCart.CurrentItems != null &&
                          shoppingCart.CurrentItems.Any(i => honors2016Skus.Contains(i.SKU)))
                 {
                     var message = "SKUNotAvailable";
                     var globalResourceObject =
                         HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform),
                                                             "SKUNotAvailable");
                     if (globalResourceObject != null)
                     {
                         message = string.Format(globalResourceObject.ToString(), shoppingCart.CurrentItems[0].SKU);
                     }
                     ruleResult.AddMessage(message);
                     ruleResult.Result = RulesResult.Failure;
                 }
             }
         }
         else
         {
             if (cart != null && cart.DeliveryInfo != null &&
                 cart.DeliveryInfo.Option == DeliveryOptionType.Pickup &&
                 cart.DeliveryInfo.WarehouseCode == HLConfigManager.Configurations.PickupOrDeliveryConfiguration.SpecialEventWareHouse)
             {
                 var message = "SKUNotAvailable";
                 var globalResourceObject =
                     HttpContext.GetGlobalResourceObject(string.Format("{0}_ErrorMessage", HLConfigManager.Platform),
                                                         "SKUNotAvailable");
                 if (globalResourceObject != null)
                 {
                     message = string.Format(globalResourceObject.ToString(), shoppingCart.CurrentItems[0].SKU);
                 }
                 ruleResult.AddMessage(message);
                 ruleResult.Result = RulesResult.Failure;
             }
         }
     }
     return(ruleResult);
 }