public static LineItem ToWebModel(this VirtoCommerceCartModuleWebModelLineItem serviceModel, Currency currency, Language language)
        {
            var webModel = new LineItem(currency, language);

            webModel.InjectFrom<NullableAndEnumValueInjecter>(serviceModel);

            if (serviceModel.TaxDetails != null)
            {
                webModel.TaxDetails = serviceModel.TaxDetails.Select(td => td.ToWebModel()).ToList();
            }

            if (serviceModel.DynamicProperties != null)
            {
                webModel.DynamicProperties = serviceModel.DynamicProperties.Select(dp => dp.ToWebModel()).ToList();
            }

            webModel.DiscountTotal = new Money(serviceModel.DiscountTotal ?? 0, currency.Code);
            webModel.ExtendedPrice = new Money(serviceModel.ExtendedPrice ?? 0, currency.Code);
            webModel.IsGift = (bool)serviceModel.IsGift;
            webModel.IsReccuring = (bool)serviceModel.IsReccuring;
            webModel.Length = (decimal)(serviceModel.Length ?? 0);
            webModel.ListPrice = new Money(serviceModel.ListPrice ?? 0, currency.Code);
            webModel.PlacedPrice = new Money(serviceModel.PlacedPrice ?? 0, currency.Code);
            webModel.RequiredShipping = (bool)serviceModel.RequiredShipping;
            webModel.SalePrice = new Money(serviceModel.SalePrice ?? 0, currency.Code);
            webModel.TaxIncluded = (bool)serviceModel.TaxIncluded;
            webModel.Weight = (decimal)(serviceModel.Weight ?? 0);
            webModel.Width = (decimal)(serviceModel.Width ?? 0);

            return webModel;
        }
        public static PaymentIn ToWebModel(this VirtoCommerceOrderModuleWebModelPaymentIn paymentIn)
        {
            var webModel = new PaymentIn();

            var currency = new Currency(EnumUtility.SafeParse(paymentIn.Currency, CurrencyCodes.USD));

            webModel.InjectFrom(paymentIn);

            if (paymentIn.ChildrenOperations != null)
            {
                webModel.ChildrenOperations = paymentIn.ChildrenOperations.Select(co => co.ToWebModel()).ToList();
            }

            webModel.Currency = currency;

            if (paymentIn.DynamicProperties != null)
            {
                webModel.DynamicProperties = paymentIn.DynamicProperties.Select(dp => dp.ToWebModel()).ToList();
            }

            webModel.Sum = new Money(paymentIn.Sum ?? 0, currency.Code);
            webModel.Tax = new Money(paymentIn.Tax ?? 0, currency.Code);

            return webModel;
        }
        public static Operation ToWebModel(this VirtoCommerceOrderModuleWebModelOperation operation)
        {
            var operationWebModel = new Operation();

            var currency = new Currency(EnumUtility.SafeParse(operation.Currency, CurrencyCodes.USD));

            operationWebModel.InjectFrom(operation);

            operationWebModel.Currency = currency;

            if (operation.ChildrenOperations != null)
            {
                operationWebModel.ChildrenOperations = operation.ChildrenOperations.Select(co => co.ToWebModel()).ToList();
            }

            if (operation.DynamicProperties != null)
            {
                operationWebModel.DynamicProperties = operation.DynamicProperties.Select(dp => dp.ToWebModel()).ToList();
            }

            operationWebModel.Sum = new Money(operation.Sum ?? 0, currency.Code);
            operationWebModel.Tax = new Money(operation.Tax ?? 0, currency.Code);

            return operationWebModel;
        }
        public static LineItem ToWebModel(this VirtoCommerceOrderModuleWebModelLineItem lineItem)
        {
            var webModel = new LineItem();

            var currency = new Currency(EnumUtility.SafeParse(lineItem.Currency, CurrencyCodes.USD));

            webModel.InjectFrom(lineItem);

            webModel.Currency = currency;
            webModel.DiscountAmount = new Money(lineItem.DiscountAmount ?? 0, currency.Code);

            if (lineItem.DynamicProperties != null)
            {
                webModel.DynamicProperties = lineItem.DynamicProperties.Select(dp => dp.ToWebModel()).ToList();
            }

            webModel.Price = new Money(lineItem.Price ?? 0, currency.Code);
            webModel.Tax = new Money(lineItem.Tax ?? 0, currency.Code);

            if (lineItem.TaxDetails != null)
            {
                webModel.TaxDetails = lineItem.TaxDetails.Select(td => td.ToWebModel()).ToList();
            }

            return webModel;
        }
        public static TaxDetail ToWebModel(this VirtoCommerceDomainCommerceModelTaxDetail taxDetail, Currency currency)
        {
            var taxDetailWebModel = new TaxDetail(currency);

            taxDetailWebModel.InjectFrom(taxDetail);

            return taxDetailWebModel;
        }
        public static Model.Order.Shipment ToWebModel(this VirtoCommerceOrderModuleWebModelShipment shipment)
        {
            var webModel = new Model.Order.Shipment();

            var currency = new Currency(EnumUtility.SafeParse(shipment.Currency, CurrencyCodes.USD));

            webModel.InjectFrom(shipment);

            if (shipment.ChildrenOperations != null)
            {
                webModel.ChildrenOperations = shipment.ChildrenOperations.Select(co => co.ToWebModel()).ToList();
            }

            webModel.Currency = currency;

            if (shipment.DeliveryAddress != null)
            {
                webModel.DeliveryAddress = shipment.DeliveryAddress.ToWebModel();
            }

            if (shipment.Discount != null)
            {
                webModel.Discount = shipment.Discount.ToWebModel();
            }

            webModel.DiscountAmount = new Money(shipment.DiscountAmount ?? 0, currency.Code);

            if (shipment.DynamicProperties != null)
            {
                webModel.DynamicProperties = shipment.DynamicProperties.Select(dp => dp.ToWebModel()).ToList();
            }

            if (shipment.InPayments != null)
            {
                webModel.InPayments = shipment.InPayments.Select(p => p.ToWebModel()).ToList();
            }

            if (shipment.Items != null)
            {
                webModel.Items = shipment.Items.Select(i => i.ToWebModel()).ToList();
            }

            if (shipment.Packages != null)
            {
                webModel.Packages = shipment.Packages.Select(p => p.ToWebModel()).ToList();
            }

            webModel.Sum = new Money(shipment.Sum ?? 0, currency.Code);
            webModel.Tax = new Money(shipment.Tax ?? 0, currency.Code);

            if (shipment.TaxDetails != null)
            {
                webModel.TaxDetails = shipment.TaxDetails.Select(td => td.ToWebModel()).ToList();
            }

            return webModel;
        }
        public static TierPrice ToWebModel(this VirtoCommerceQuoteModuleWebModelTierPrice serviceModel, Currency currency)
        {
            var webModel = new TierPrice(currency);

            webModel.InjectFrom<NullableAndEnumValueInjecter>(serviceModel);

            webModel.Price = new Money(serviceModel.Price ?? 0, currency);

            return webModel;
        }
        public static ShippingMethod ToWebModel(this VirtoCommerceQuoteModuleWebModelShipmentMethod serviceModel, Currency currency)
        {
            var webModel = new ShippingMethod();

            webModel.InjectFrom<NullableAndEnumValueInjecter>(serviceModel);

            webModel.Price = new Money(serviceModel.Price ?? 0, currency);

            return webModel;
        }
        public static TierPrice ToTierPrice(this VirtoCommercePricingModuleWebModelPrice serviceModel, Currency currency)
        {
            var listPrice = new Money(serviceModel.List ?? 0, currency);

            return new TierPrice(currency)
            {
                Quantity = serviceModel.MinQuantity ?? 1,
                Price = serviceModel.Sale.HasValue ? new Money(serviceModel.Sale.Value, currency) : listPrice
            };
        }
        public static Payment ToPaymentModel(this PaymentMethod paymentMethod, Money amount, Currency currency)
        {
            var paymentWebModel = new Payment();

            paymentWebModel.Amount = amount;
            paymentWebModel.Currency = currency;
            paymentWebModel.PaymentGatewayCode = paymentMethod.GatewayCode;

            return paymentWebModel;
        }
        public static Shipment ToShipmentModel(this ShippingMethod shippingMethod, Currency currency)
        {
            var shipmentWebModel = new Shipment(currency);

            shipmentWebModel.ShipmentMethodCode = shippingMethod.ShipmentMethodCode;
            shipmentWebModel.ShippingPrice = shippingMethod.Price;
            shipmentWebModel.TaxType = shippingMethod.TaxType;

            return shipmentWebModel;
        }
示例#12
0
 public Shipment(Currency currency)
 {
     Currency = currency;
     Discounts = new List<Discount>();
     Items = new List<CartShipmentItem>();
     TaxDetails = new List<TaxDetail>();
     ValidationErrors = new List<ValidationError>();
     ValidationWarnings = new List<ValidationError>();
     ShippingPrice = new Money(currency);
     TaxTotal = new Money(currency);
 }
 public QuoteRequestTotals(Currency currency)
 {
     OriginalSubTotalExlTax = new Money(currency);
     SubTotalExlTax = new Money(currency);
     ShippingTotal = new Money(currency);
     DiscountTotal = new Money(currency);
     TaxTotal = new Money(currency);
     AdjustmentQuoteExlTax = new Money(currency);
     GrandTotalExlTax = new Money(currency);
     GrandTotalInclTax = new Money(currency);
 }
示例#14
0
        public static CustomerOrder ToWebModel(this VirtoCommerceOrderModuleWebModelCustomerOrder order)
        {
            var webModel = new CustomerOrder();

            var currency = new Currency(EnumUtility.SafeParse(order.Currency, CurrencyCodes.USD));

            webModel.InjectFrom(order);

            if (order.Addresses != null)
            {
                webModel.Addresses = order.Addresses.Select(a => a.ToWebModel()).ToList();
            }

            if (order.ChildrenOperations != null)
            {
                webModel.ChildrenOperations = order.ChildrenOperations.Select(co => co.ToWebModel()).ToList();
            }

            webModel.Currency = currency;

            webModel.DiscountAmount = new Money(order.DiscountAmount ?? 0, currency.Code);

            if (order.DynamicProperties != null)
            {
                webModel.DynamicProperties = order.DynamicProperties.Select(dp => dp.ToWebModel()).ToList();
            }

            if (order.InPayments != null)
            {
                webModel.InPayments = order.InPayments.Select(p => p.ToWebModel()).ToList();
            }

            if (order.Items != null)
            {
                webModel.Items = order.Items.Select(i => i.ToWebModel()).ToList();
            }

            if (order.Shipments != null)
            {
                webModel.Shipments = order.Shipments.Select(s => s.ToWebModel()).ToList();
            }

            webModel.Sum = new Money(order.Sum ?? 0, currency.Code);
            webModel.Tax = new Money(order.Tax ?? 0, currency.Code);

            if (order.TaxDetails != null)
            {
                webModel.TaxDetails = order.TaxDetails.Select(td => td.ToWebModel()).ToList();
            }

            return webModel;
        }
示例#15
0
 public static ProductPrice ToWebModel(this VirtoCommercePricingModuleWebModelPrice price)
 {
     var currency = new Currency(EnumUtility.SafeParse<CurrencyCodes>(price.Currency, CurrencyCodes.USD));
     var retVal = new ProductPrice(currency);
     retVal.InjectFrom(price);
     retVal.Currency = currency;
     retVal.ListPrice = new Money((decimal)(price.List ?? 0), price.Currency);
     retVal.SalePrice = price.Sale == null ? retVal.ListPrice : new Money((decimal)price.Sale, price.Currency);
     retVal.AbsoluteBenefit = retVal.ListPrice - retVal.SalePrice;
     retVal.ActiveDiscount = new Discount { Amount = new Money(0, price.Currency) };
     retVal.ActualPrice = retVal.SalePrice - retVal.ActiveDiscount.Amount;
     return retVal;
 }
        public static QuoteRequestTotals ToWebModel(this VirtoCommerceQuoteModuleWebModelQuoteRequestTotals serviceModel, Currency currency)
        {
            var webModel = new QuoteRequestTotals(currency);

            webModel.AdjustmentQuoteExlTax = new Money(serviceModel.AdjustmentQuoteExlTax ?? 0, currency);
            webModel.DiscountTotal = new Money(serviceModel.DiscountTotal ?? 0, currency);
            webModel.GrandTotalExlTax = new Money(serviceModel.GrandTotalExlTax ?? 0, currency);
            webModel.GrandTotalInclTax = new Money(serviceModel.GrandTotalInclTax ?? 0, currency);
            webModel.OriginalSubTotalExlTax = new Money(serviceModel.OriginalSubTotalExlTax ?? 0, currency);
            webModel.ShippingTotal = new Money(serviceModel.ShippingTotal ?? 0, currency);
            webModel.SubTotalExlTax = new Money(serviceModel.SubTotalExlTax ?? 0, currency);
            webModel.TaxTotal = new Money(serviceModel.TaxTotal ?? 0, currency);

            return webModel;
        }
        public static PromotionReward ToWebModel(this VirtoCommerceMarketingModuleWebModelPromotionReward serviceModel, Currency currency)
        {
            var webModel = new PromotionReward();

            webModel.InjectFrom<NullableAndEnumValueInjecter>(serviceModel);

            webModel.Amount = (decimal)(serviceModel.Amount ?? 0);
            webModel.AmountType = EnumUtility.SafeParse(serviceModel.AmountType, AmountType.Absolute);
            webModel.CouponAmount = new Money(serviceModel.CouponAmount ?? 0, currency.Code);
            webModel.CouponMinOrderAmount = new Money(serviceModel.CouponMinOrderAmount ?? 0, currency.Code);
            webModel.Promotion = serviceModel.Promotion.ToWebModel();
            webModel.RewardType = EnumUtility.SafeParse(serviceModel.RewardType, PromotionRewardType.CatalogItemAmountReward);
            webModel.ShippingMethodCode = serviceModel.ShippingMethod;

            return webModel;
        }
        public static ShippingMethod ToWebModel(this VirtoCommerceCartModuleWebModelShippingMethod shippingMethod)
        {
            var shippingMethodModel = new ShippingMethod();

            shippingMethodModel.InjectFrom(shippingMethod);

            var currency = new Currency(EnumUtility.SafeParse(shippingMethod.Currency, CurrencyCodes.USD));

            if (shippingMethod.Discounts != null)
            {
                shippingMethodModel.Discounts = shippingMethod.Discounts.Select(d => d.ToWebModel()).ToList();
            }

            shippingMethodModel.Price = new Money(shippingMethod.Price ?? 0, currency.Code);

            return shippingMethodModel;
        }
        public static Payment TowebModel(this VirtoCommerceCartModuleWebModelPayment payment, Currency currency)
        {
            var webModel = new Payment(currency);

            webModel.InjectFrom(payment);

            webModel.Amount = new Money(payment.Amount ?? 0, currency);

            if (payment.BillingAddress != null)
            {
                webModel.BillingAddress = payment.BillingAddress.ToWebModel();
            }

            webModel.Currency = currency;

            return webModel;
        }
示例#20
0
        public ShoppingCart(Currency currency, Language language)
        {
            Currency = currency;
            Language = language;
            HandlingTotal = new Money(currency);
            TaxTotal = new Money(currency);

            Addresses = new List<Address>();
            Discounts = new List<Discount>();
            Items = new List<LineItem>();
            Payments = new List<Payment>();
            Shipments = new List<Shipment>();
            TaxDetails = new List<TaxDetail>();
            DynamicProperties = new List<DynamicProperty>();
            ValidationErrors = new List<ValidationError>();
            ValidationWarnings = new List<ValidationError>();
            AvailablePaymentMethods = new List<PaymentMethod>();
        }
示例#21
0
        public ShoppingCart(Currency currency, Language language)
        {
            Currency = currency;
            LanguageCode = language.CultureName;
            DiscountTotal = new Money(currency.Code);
            HandlingTotal = new Money(currency.Code);
            ShippingTotal = new Money(currency.Code);
            SubTotal = new Money(currency.Code);
            TaxTotal = new Money(currency.Code);
            Total = new Money(currency.Code);

            Addresses = new List<Address>();
            Discounts = new List<Discount>();
            Items = new List<LineItem>();
            Payments = new List<Payment>();
            Shipments = new List<Shipment>();
            TaxDetails = new List<TaxDetail>();
            DynamicProperties = new List<DynamicProperty>();
        }
示例#22
0
        public static Payment TowebModel(this VirtoCommerceCartModuleWebModelPayment payment)
        {
            var webModel = new Payment();

            var currency = new Currency(EnumUtility.SafeParse(payment.Currency, CurrencyCodes.USD));

            webModel.InjectFrom(payment);

            webModel.Amount = new Money(payment.Amount ?? 0, currency.Code);

            if (payment.BillingAddress != null)
            {
                webModel.BillingAddress = payment.BillingAddress.ToWebModel();
            }

            webModel.Currency = currency;

            return webModel;
        }
        public static QuoteItem ToWebModel(this VirtoCommerceQuoteModuleWebModelQuoteItem serviceModel, Currency currency)
        {
            var webModel = new QuoteItem();

            webModel.InjectFrom<NullableAndEnumValueInjecter>(serviceModel);

            webModel.Currency = currency;
            webModel.ListPrice = new Money(serviceModel.ListPrice ?? 0, currency);
            webModel.SalePrice = new Money(serviceModel.SalePrice ?? 0, currency);

            if (serviceModel.ProposalPrices != null)
            {
                webModel.ProposalPrices = serviceModel.ProposalPrices.Select(pp => pp.ToWebModel(currency)).ToList();
            }

            if (serviceModel.SelectedTierPrice != null)
            {
                webModel.SelectedTierPrice = serviceModel.SelectedTierPrice.ToWebModel(currency);
            }

            return webModel;
        }
示例#24
0
 public TaxDetail(Currency currency)
 {
     Rate = new Money(currency);
     Amount = new Money(currency);
 }
        public static Shipment ToShipmentModel(this ShipmentUpdateModel updateModel, Currency currency)
        {
            var shipmentModel = new Shipment(currency);

            shipmentModel.InjectFrom<NullableAndEnumValueInjecter>(updateModel);

            return shipmentModel;
        }
示例#26
0
 public Payment(Currency currency)
 {
     Amount = new Money(currency);
     Currency = currency;
 }
示例#27
0
        public Discount ToDiscountModel(decimal originAmount, Currency currency)
        {
            decimal absoluteAmount = GetAbsoluteDiscountAmount(originAmount);

            var discount = new Discount();
            discount.Amount = new Money(absoluteAmount, currency.Code);
            discount.Description = Promotion.Description;
            discount.PromotionId = Promotion.Id;

            return discount;
        }