public static string GetTaxIdentificationId(string distributorID, string tinId)
        {
            var    tinList                    = new List <TaxIdentification>();
            string isoCountryCode             = Thread.CurrentThread.CurrentCulture.Name.Substring(3);
            var    distributorOrderingProfile = new DistributorOrderingProfileFactory().ReloadDistributorOrderingProfile(distributorID, isoCountryCode);
            var    countryCodes               = new List <string>();

            countryCodes.Add(isoCountryCode);
            countryCodes.AddRange(HL.Common.ValueObjects.CountryType.Parse(isoCountryCode).HmsCountryCodes);
            var now = DateUtils.GetCurrentLocalTime(isoCountryCode);

            if (distributorOrderingProfile != null && distributorOrderingProfile.TinList != null)
            {
                var tin = distributorOrderingProfile.TinList.Where(t => t.IDType != null && t.IDType.Key == tinId).FirstOrDefault();
                if (tin != null)
                {
                    return(tin.ID);
                }
            }

            return(null);
        }
        public IPurchaseRestrictionManager GetPurchaseRestrictionManager(string id)
        {
            //Load the DS/get it from cache..
            ILoader <DistributorProfileModel, GetDistributorProfileById> distributorProfileLoader = new DistributorProfileLoader();
            var locale = CultureInfo.CurrentCulture.Name;
            var currentLoggedInCounrtyCode = locale.Substring(3);
            var distributorProfileModel    = distributorProfileLoader.Load(new GetDistributorProfileById {
                Id = id
            });

            // to prevent recusive calls
            // get distributor ordering profile from Distributor_V01
            DistributorLoader distributorLoader = new DistributorLoader();
            var distributorProfile         = distributorLoader.Load(id, currentLoggedInCounrtyCode);
            var distributorOrderingProfile = DistributorOrderingProfileFactory.GetDistributorOrderingProfile(distributorProfile, currentLoggedInCounrtyCode);

            return(_Cache.Retrieve(delegate
            {
                return new PurchaseRestrictionManager(id, currentLoggedInCounrtyCode, distributorProfileModel.TypeCode, distributorProfileModel.ProcessingCountryCode, locale, distributorOrderingProfile.TinList, distributorOrderingProfile.OrderSubType);
            }, GetCacheKey(id, currentLoggedInCounrtyCode), TimeSpan.FromMinutes(Settings.GetRequiredAppSetting(
                                                                                     "PurchasingLimitsCacheMinutes",
                                                                                     30))));
        }
Ejemplo n.º 3
0
        public static DistributorOrderingProfile GetDistributorOrderingProfile(string memberId, string countryCode)
        {
            var distributorOrderingProfileFactory = new DistributorOrderingProfileFactory();

            return(distributorOrderingProfileFactory.GetDistributorOrderingProfile(memberId, countryCode));
        }