public static Discount ToWebModel(this VirtoCommerceCartModuleWebModelDiscount serviceModel)
        {
            var webModel = new Discount();

            webModel.InjectFrom(serviceModel);

            webModel.Amount = new Money(serviceModel.DiscountAmount ?? 0, serviceModel.Currency);

            return(webModel);
        }
Пример #2
0
        public static VirtoCommerceCartModuleWebModelDiscount ToServiceModel(this Discount webModel)
        {
            var serviceModel = new VirtoCommerceCartModuleWebModelDiscount();

            serviceModel.InjectFrom(webModel);

            serviceModel.Currency = webModel.Amount.CurrencyCode;
            serviceModel.DiscountAmount = (double)webModel.Amount.Amount;

            return serviceModel;
        }
Пример #3
0
        public static VirtoCommerceCartModuleWebModelDiscount ToServiceModel(this Discount webModel)
        {
            var serviceModel = new VirtoCommerceCartModuleWebModelDiscount();

            serviceModel.InjectFrom(webModel);

            serviceModel.Currency       = webModel.Amount.Currency.Code;
            serviceModel.DiscountAmount = (double)webModel.Amount.Amount;

            return(serviceModel);
        }
Пример #4
0
        public static Discount ToWebModel(this VirtoCommerceCartModuleWebModelDiscount serviceModel, IEnumerable <Currency> availCurrencies, Language language)
        {
            var webModel = new Discount();

            webModel.InjectFrom(serviceModel);
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(serviceModel.Currency)) ?? new Currency(language, serviceModel.Currency);

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

            return(webModel);
        }