private void checkLimits(MyHLShoppingCart hlCart) { var currentLimits = PurchasingLimitProvider.GetCurrentPurchasingLimits(hlCart.DistributorID); var session = SessionInfo.GetSessionInfo(hlCart.DistributorID, hlCart.Locale); string trainingCode = HLConfigManager.Configurations.ShoppingCartConfiguration.TrainingCode; if (session.DsTrainings == null || session.DsTrainings.Count == 0) { session.DsTrainings = DistributorOrderingProfileProvider.GetTrainingList(hlCart.DistributorID, hlCart.CountryCode); } if (session.DsTrainings != null && session.DsTrainings.Count > 0 && session.DsTrainings.Exists(t => t.TrainingCode == trainingCode && !t.TrainingFlag)) { //if is true the member place an order without taking the training and the limits shoud be applicable for only 1100 if (currentLimits.RemainingVolume != currentLimits.maxVolumeLimit && !session.LimitsHasModified) { var used = (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume); var shouldbe = 1100 - used; PurchaseLimitType limitType = PurchaseLimitType.Volume; currentLimits.PurchaseLimitType = limitType; if (currentLimits.RemainingVolume != shouldbe && shouldbe > 0 && !session.LimitsHasModified) { currentLimits.RemainingVolume = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV - (currentLimits.maxVolumeLimit - currentLimits.RemainingVolume); session.LimitsHasModified = true; } string country = DistributorProfileModel.ProcessingCountryCode; PurchasingLimitProvider.savePurchasingLimitsToCache(ConvertCurrentLimitsToSave(currentLimits), hlCart.DistributorID); PurchasingLimitProvider.SavePurchaseLimitsToStore(country, hlCart.DistributorID); } //check for the members without limits and create else if (currentLimits.RemainingVolume == -1 && currentLimits.maxVolumeLimit == -1 && !session.LimitsHasModified) { var currentLoggedInCounrtyCode = Locale.Substring(3); DistributorLoader distributorLoader = new DistributorLoader(); var distributorProfile = distributorLoader.Load(hlCart.DistributorID, currentLoggedInCounrtyCode); var remainingVolume = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV - distributorProfile.PersonallyPurchasedVolume; PurchaseLimitType limitType = PurchaseLimitType.Volume; //PurchasingLimits_V01 newLimits = new PurchasingLimits_V01(); currentLimits.Month = currentLimits.Month; currentLimits.LastRead = DateTime.UtcNow; currentLimits.RemainingVolume = distributorProfile.PersonallyPurchasedVolume != 0 ? remainingVolume : 0; currentLimits.LimitsRestrictionType = LimitsRestrictionType.PurchasingLimits; currentLimits.PurchaseLimitType = limitType; currentLimits.LastRead = DateTime.UtcNow; currentLimits.maxVolumeLimit = HLConfigManager.Configurations.ShoppingCartConfiguration.eLearningMaxPPV; session.LimitsHasModified = true; string country = DistributorProfileModel.ProcessingCountryCode; PurchasingLimitProvider.savePurchasingLimitsToCache(ConvertCurrentLimitsToSave(currentLimits), hlCart.DistributorID); PurchasingLimitProvider.SavePurchaseLimitsToStore(country, hlCart.DistributorID); } } }