public ShippingByOrderPrice(Dictionary<string, string> parameters)
        {
            try
            {
                _priceRanges = new List<ShippingPriceRange>();

                var ranges = parameters.ElementOrDefault(ShippingByOrderPriceTemplate.PriceRanges);
                if (ranges.IsNullOrEmpty())
                    return;

                foreach (var item in ranges.Split(';'))
                {
                    if (item.Split('=').Length == 2)
                    {
                        _priceRanges.Add(new ShippingPriceRange()
                            {
                                OrderPrice = item.Split('=')[0].TryParseFloat(),
                                ShippingPrice = item.Split('=')[1].TryParseFloat()
                            });
                    }
                }

                _priceRanges = _priceRanges.OrderBy(item => item.OrderPrice).ToList();
                _dependsOnCartPrice = parameters.ElementOrDefault(ShippingByOrderPriceTemplate.DependsOnCartPrice).TryParseBool();
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
                _priceRanges = new List<ShippingPriceRange>();
            }
        }
 public ShippingByShippingCost(Dictionary<string, string> parameters)
 {
     try
     {
         _byMaxShippingCost = parameters.ElementOrDefault(ShippingByShippingCostTemplate.ByMaxShippingCost).TryParseBool();
         _useAmount = parameters.ElementOrDefault(ShippingByShippingCostTemplate.UseAmount).TryParseBool();
     }
     catch (Exception ex)
     {
         Debug.LogError(ex);
     }
 }
Example #3
0
 public ShippingByWeight(Dictionary<string, string> parameters)
 {
     try
     {
         _pricePerKg = parameters.ElementOrDefault(ShippingByWeightTemplate.PricePerKg).TryParseFloat();
         _extracharge = parameters.ElementOrDefault(ShippingByWeightTemplate.Extracharge).TryParseFloat();
     }
     catch (Exception ex)
     {
         Debug.LogError(ex);
         _pricePerKg = 0;
     }
 }
Example #4
0
        public FixeRateShipping(Dictionary<string, string> parameters)
        {
            try
            {
                _shippingPrice = parameters.ElementOrDefault(FixeRateShippingTemplate.ShippingPrice).TryParseFloat();
                _extracharge = parameters.ElementOrDefault(FixeRateShippingTemplate.Extracharge).TryParseFloat();
            }
            catch (Exception e)
            {

                Debug.LogError(e);
            }
        }
Example #5
0
        public Usps(Dictionary<string, string> parameters)
        {
            try
            {
                Rate = parameters.ElementOrDefault(UspsTemplate.Rate).TryParseFloat();
                Extracharge = parameters.ElementOrDefault(UspsTemplate.Extracharge).TryParseFloat();

                UserId = parameters.ElementOrDefault(UspsTemplate.UserId);
                Password = parameters.ElementOrDefault(UspsTemplate.Password);
                PostalCodeFrom = parameters.ElementOrDefault(UspsTemplate.PostalCode);

                EnabledService = new List<string>();
                EnabledService.AddRange(GetEnabledDomesticService(parameters));
                EnabledService.AddRange(GetEnabledInternationalService(parameters));
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }
Example #6
0
        public Ups(Dictionary<string, string> parameters)
        {
            try
            {
                AccessKey = parameters.ElementOrDefault(UpsTemplate.AccessKey);
                UserName = parameters.ElementOrDefault(UpsTemplate.UserName);
                Password = parameters.ElementOrDefault(UpsTemplate.Password);
                PostalCodeFrom = parameters.ElementOrDefault(UpsTemplate.PostalCode);
                CountryCodeFrom = parameters.ElementOrDefault(UpsTemplate.CountryCode);
                CustomerType = (UpsCustomerClassification)parameters.ElementOrDefault(UpsTemplate.CustomerClassification).TryParseInt();
                PickupType = (UpsPickupType)parameters.ElementOrDefault(UpsTemplate.PickupType).TryParseInt();
                PackagingType = (UpsPackagingType)parameters.ElementOrDefault(UpsTemplate.PackagingType).TryParseInt();
                Extracharge = parameters.ElementOrDefault(UpsTemplate.Extracharge).TryParseFloat();
                Rate = parameters.ElementOrDefault(UpsTemplate.Rate).TryParseFloat();

                EnabledService = GetEnabledService(parameters);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
        }
Example #7
0
        //Constructor
        public FedEx(Dictionary<string, string> parameters)
        {
            try
            {
                CountryCodeFrom = parameters.ElementOrDefault(FedExTemplate.CountryCode);
                PostalCodeFrom = parameters.ElementOrDefault(FedExTemplate.PostalCode);
                StateFrom = parameters.ElementOrDefault(FedExTemplate.State);
                CityFrom = parameters.ElementOrDefault(FedExTemplate.City);
                AddressFrom = parameters.ElementOrDefault(FedExTemplate.Address);
                AccountNumber = parameters.ElementOrDefault(FedExTemplate.AccountNumber);
                MeterNumber = parameters.ElementOrDefault(FedExTemplate.MeterNumber);
                Rate = parameters.ElementOrDefault(FedExTemplate.Rate).TryParseFloat();
                Extracharge = parameters.ElementOrDefault(FedExTemplate.Extracharge).TryParseFloat();
                Key = parameters.ElementOrDefault(FedExTemplate.Key);
                Password = parameters.ElementOrDefault(FedExTemplate.Password);

                EnabledService = GetEnabledService(parameters);
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
        }
Example #8
0
        public SaasData(Dictionary<string, string> parameters)
        {
            if (parameters == null)
            {
                IsCorrect = false;
                return;
            }

            if (parameters.ContainsKey(SaasDataTemplate.Error))
            {
                IsCorrect = false;
                return;
            }
            //throw new Exception("error with get saas");

            Name = parameters.ElementOrDefault(SaasDataTemplate.Name);
            ProductsCount = parameters.ElementOrDefault(SaasDataTemplate.ProductsCount).TryParseInt();
            PhotosCount = parameters.ElementOrDefault(SaasDataTemplate.PhotosCount).TryParseInt();
            HaveExcel = parameters.ElementOrDefault(SaasDataTemplate.HaveExcel).TryParseBool();
            Have1C = parameters.ElementOrDefault(SaasDataTemplate.Have1C).TryParseBool();
            HaveExportFeeds = parameters.ElementOrDefault(SaasDataTemplate.HaveExportFeeds).TryParseBool();
            HavePriceRegulating = parameters.ElementOrDefault(SaasDataTemplate.HavePriceRegulating).TryParseBool();
            HaveBankIntegration = parameters.ElementOrDefault(SaasDataTemplate.HaveBankIntegration).TryParseBool();

            IsWork = parameters.ElementOrDefault(SaasDataTemplate.IsWork).TryParseBool();
            LeftDay = parameters.ElementOrDefault(SaasDataTemplate.LeftDay).TryParseInt();
            Money = parameters.ElementOrDefault(SaasDataTemplate.Money) != null ? parameters.ElementOrDefault(SaasDataTemplate.Money).Replace(".", ",").TryParseDecimal() : 0;
            Bonus = parameters.ElementOrDefault(SaasDataTemplate.Bonus) != null ? parameters.ElementOrDefault(SaasDataTemplate.Bonus).Replace(".", ",").TryParseDecimal() : 0;
            LastUpdate = parameters.ElementOrDefault(SaasDataTemplate.LastUpdate).TryParseDateTime(DateTime.MinValue, CultureInfo.InvariantCulture, DateTimeStyles.None);
            IsCorrect = true;
        }
Example #9
0
 public static bool GetBooleanParam(Dictionary<string, string> items, string paramName)
 {
     return items.ElementOrDefault(paramName).TryParseBool();
 }