private PublicOrder CreateBasicOrder()
        {
            string country             = this.countryProvider.GetDefaultCountry().Code;
            var    vatValidationResult = vatNumberValidator.ValidateCustomerVatNumber();
            var    vatNumber           = string.Empty;


            if (vatValidationResult != null && vatValidationResult.Valid)
            {
                vatNumber = vatValidationResult.VatNumber;
                country   = vatValidationResult.CountryCode;
            }
            else if (this.contactDataProvider != null)
            {
                var allContacts = this.contactDataProvider.GetContactData();
                IEnumerable <ContactData> contacts = allContacts?.GetContactData();
                if (contacts != null)
                {
                    ContactData contactData = contacts.FirstOrDefault(c => c.Id == "BillingContact" && !string.IsNullOrEmpty(c.Country))
                                              ?? contacts.FirstOrDefault(c => c.Id == "MainContact" && !string.IsNullOrEmpty(c.Country));
                    if (!string.IsNullOrEmpty(contactData?.Country))
                    {
                        country = contactData.Country;
                    }
                }
            }

            return(new PublicOrder
            {
                ResellerId = resellerProvider.GetReseller().Id,
                Country = country,
                Currency = currencyPreferenceProvider.GetCurrentCurrency().Code,
                LegalNumber = vatNumber
            });
        }
Ejemplo n.º 2
0
        private PublicOrder CreateBasicOrder()
        {
            string country = this.countryProvider.GetDefaultCountry().Code;

            if (this.contactDataProvider != null)
            {
                var allContacts = this.contactDataProvider.GetContactData();
                IEnumerable <ContactData> contacts = allContacts?.GetContactData();
                if (contacts != null)
                {
                    ContactData contactData = contacts.FirstOrDefault(c => c.Id == "BillingContact" && !string.IsNullOrEmpty(c.Country))
                                              ?? contacts.FirstOrDefault(c => c.Id == "MainContact" && !string.IsNullOrEmpty(c.Country));
                    if (!string.IsNullOrEmpty(contactData?.Country))
                    {
                        country = contactData.Country;
                    }
                }
            }

            return(new PublicOrder
            {
                ResellerId = resellerProvider.GetReseller().Id,
                Country = country,
                Currency = currencyPreferenceProvider.GetCurrentCurrency().Code
            });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set order currency from customer's currency preference
        /// </summary>
        public override PublicOrder AmendOrder(PublicOrder order, PublicOrderContext orderContext)
        {
            var currency = currencyPreferenceProvider.GetCurrentCurrency();

            order.Currency = currency.Code;

            return(order);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Construct a new instance
        /// </summary>
        public DomainsProvider(
            IResellerDataProvider resellerDataProvider,
            ICurrencyPreferenceProvider currencyPreferenceProvider,
            ApiProductsProvider apiProductsProvider,
            ProductMapper productMapper,
            PublicBillingApiProxy billingApi,
            IShopNameProvider shopNameProvider) : base(billingApi)
        {
            if (resellerDataProvider == null)
            {
                throw new ArgumentException("resellerDataProvider");
            }

            if (currencyPreferenceProvider == null)
            {
                throw new ArgumentException("currencyPreferenceProvider");
            }

            if (apiProductsProvider == null)
            {
                throw new ArgumentNullException("apiProductsProvider");
            }

            if (productMapper == null)
            {
                throw new ArgumentNullException("productMapper");
            }

            if (shopNameProvider == null)
            {
                throw new ArgumentNullException("shopNameProvider");
            }

            var resellerData = resellerDataProvider.GetResellerAccountData();

            this.resellerId       = resellerData.Id;
            this.countryCode      = resellerData.DefaultCountry.Code;
            this.currencyCode     = currencyPreferenceProvider.GetCurrentCurrency().Code;
            this.productMapper    = productMapper;
            this.shopNameProvider = shopNameProvider;

            this.tldProducts = apiProductsProvider.GetProductsByCategories(new List <string> {
                "TLD"
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Construct a new instance
        /// </summary>
        public DomainsProvider(
            IResellerDataProvider resellerDataProvider, 
            ICurrencyPreferenceProvider currencyPreferenceProvider, 
            ApiProductsProvider apiProductsProvider, 
            ProductMapper productMapper,
            PublicBillingApiProxy billingApi,
            IShopNameProvider shopNameProvider) : base(billingApi)
        {
            if (resellerDataProvider == null)
            {
                throw new ArgumentException("resellerDataProvider");
            }

            if (currencyPreferenceProvider == null)
            {
                throw new ArgumentException("currencyPreferenceProvider");
            }

            if (apiProductsProvider == null)
            {
                throw new ArgumentNullException("apiProductsProvider");
            }

            if (productMapper == null)
            {
                throw new ArgumentNullException("productMapper");
            }

            if (shopNameProvider == null)
            {
                throw new ArgumentNullException("shopNameProvider");
            }

            var resellerData = resellerDataProvider.GetResellerAccountData();

            this.resellerId = resellerData.Id;
            this.countryCode = resellerData.DefaultCountry.Code;
            this.currencyCode = currencyPreferenceProvider.GetCurrentCurrency().Code;
            this.productMapper = productMapper;
            this.shopNameProvider = shopNameProvider;

            this.tldProducts = apiProductsProvider.GetProductsByCategories(new List<string> { "TLD" });
        }
Ejemplo n.º 6
0
        public ProductMapper(ILanguagePreferenceProvider languagePreferenceProvider, ICurrencyPreferenceProvider currencyPreferenceProvider, IVatDisplayPreferenceProvider vatDisplayPreferenceProvider, IResellerProvider resellerProvider)
        {
            if (languagePreferenceProvider == null)
            {
                throw new ArgumentNullException("languagePreferenceProvider");
            }

            if (currencyPreferenceProvider == null)
            {
                throw new ArgumentNullException("currencyPreferenceProvider");
            }

            if (vatDisplayPreferenceProvider == null)
            {
                throw new ArgumentNullException("vatDisplayPreferenceProvider");
            }

            this.language                    = languagePreferenceProvider.GetCurrentLanguage();
            this.currencyCode                = currencyPreferenceProvider.GetCurrentCurrency().Code;
            this.pricesIncludeVat            = vatDisplayPreferenceProvider.ShowPricesIncludingVat();
            this.inclusiveTaxCalculationType = resellerProvider.GetReseller().InclusiveTaxCalculationType;
        }
Ejemplo n.º 7
0
        public ProductMapper(ILanguagePreferenceProvider languagePreferenceProvider, ICurrencyPreferenceProvider currencyPreferenceProvider, IVatDisplayPreferenceProvider vatDisplayPreferenceProvider, IResellerProvider resellerProvider)
        {
            if (languagePreferenceProvider == null)
            {
                throw new ArgumentNullException("languagePreferenceProvider");
            }

            if (currencyPreferenceProvider == null)
            {
                throw new ArgumentNullException("currencyPreferenceProvider");
            }

            if (vatDisplayPreferenceProvider == null)
            {
                throw new ArgumentNullException("vatDisplayPreferenceProvider");
            }

            this.language = languagePreferenceProvider.GetCurrentLanguage();
            this.currencyCode = currencyPreferenceProvider.GetCurrentCurrency().Code;
            this.pricesIncludeVat = vatDisplayPreferenceProvider.ShowPricesIncludingVat();
            this.inclusiveTaxCalculationType = resellerProvider.GetReseller().InclusiveTaxCalculationType;
        }
 public CurrencyFormatter()
 {
     this.currencyCode = currencyPreferenceProvider.GetCurrentCurrency().Code;
     this.culture      = CultureInfo.GetCultures(CultureTypes.SpecificCultures).First(c => new RegionInfo(c.LCID).ISOCurrencySymbol == currencyCode.ToUpper());
 }