Exemplo n.º 1
0
        private static ProductV3 Convert(KeyValuePair <string, ProductV2> v2, Dictionary <string, string> constants)
        {
            if (v2.Value == null)
            {
                return(null);
            }
            v2.Value.price = Calc.Replace(v2.Value.price, constants);
            var productV3 = new ProductV3
            {
                count = v2.Value.count,
                name  = v2.Value.name,
                price = v2.Value.price == null ? (decimal?)null : Calc.Evaluate(v2.Value.price),
                id    = int.Parse(v2.Key)
            };

            if (v2.Value.size != null && v2.Value.size.Length != 0)
            {
                productV3.dimensions = new Dimensions
                {
                    w = v2.Value.size[0],
                    h = v2.Value.size[1],
                    l = v2.Value.size[2],
                };
            }
            return(productV3);
        }
Exemplo n.º 2
0
        private static ProductV3 FixV3(ProductV3 v3, Dictionary <string, string> constants)
        {
            if (v3 == null)
            {
                return(null);
            }
            if (v3.price == null)
            {
                return(v3);
            }
            var price = v3.price?.ToString(CultureInfo.InvariantCulture);

            price    = decimal.Parse(Calc.Replace(price, constants), CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture);
            v3.price = Calc.Evaluate(price);
            return(v3);
        }