Exemplo n.º 1
0
        public virtual Discount ToDiscount(cartDto.Discount discountDto, IEnumerable <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(discountDto.Currency)) ?? new Currency(language, discountDto.Currency);

            var result = ServiceLocator.Current.GetInstance <MarketingFactory>().CreateDiscount(currency);

            result.InjectFrom <NullableAndEnumValueInjecter>(discountDto);
            result.Amount = new Money(discountDto.DiscountAmount ?? 0, currency);

            return(result);
        }
Exemplo n.º 2
0
        public virtual cartDto.Discount ToCartDiscountDto(Discount webModel)
        {
            var result = new cartDto.Discount();

            result.InjectFrom <NullableAndEnumValueInjecter>(webModel);

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

            return(result);
        }
Exemplo n.º 3
0
        public virtual Discount ToDiscount(cartDto.Discount discountDto, IEnumerable <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(discountDto.Currency)) ?? new Currency(language, discountDto.Currency);

            var result = new Discount(currency);

            result.InjectFrom <NullableAndEnumValueInjecter>(discountDto);
            result.Amount = new Money(discountDto.DiscountAmount ?? 0, currency);

            return(result);
        }
Exemplo n.º 4
0
        public virtual cartDto.Discount ToCartDiscountDto(Discount discount)
        {
            var result = new cartDto.Discount();

            result.PromotionId    = discount.PromotionId;
            result.Coupon         = discount.Coupon;
            result.Description    = discount.Description;
            result.Currency       = discount.Amount.Currency.Code;
            result.DiscountAmount = (double)discount.Amount.Amount;
            return(result);
        }
Exemplo n.º 5
0
        public static cartDto.Discount ToCartDiscountDto(this Discount discount)
        {
            var result = new cartDto.Discount
            {
                PromotionId    = discount.PromotionId,
                Coupon         = discount.Coupon,
                Description    = discount.Description,
                Currency       = discount.Amount.Currency.Code,
                DiscountAmount = (double)discount.Amount.Amount
            };

            return(result);
        }
Exemplo n.º 6
0
        public virtual Discount ToDiscount(cartDto.Discount discountDto, IEnumerable <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(discountDto.Currency)) ?? new Currency(language, discountDto.Currency);

            var result = new Discount(currency);

            result.Coupon      = discountDto.Coupon;
            result.Description = discountDto.Description;
            result.PromotionId = discountDto.PromotionId;
            result.Amount      = new Money(discountDto.DiscountAmount ?? 0, currency);

            return(result);
        }
Exemplo n.º 7
0
 public static Discount ToDiscount(this cartDto.Discount discountDto, IEnumerable <Currency> availCurrencies, Language language)
 {
     return(CartConverterInstance.ToDiscount(discountDto, availCurrencies, language));
 }