예제 #1
0
        public virtual LineItem ToOrderLineItem(orderDto.LineItem lineItemDto, IEnumerable <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(lineItemDto.Currency)) ?? new Currency(language, lineItemDto.Currency);

            var result = new LineItem(currency);

            result.InjectFrom <NullableAndEnumValueInjecter>(lineItemDto);
            result.ImageUrl       = result.ImageUrl.RemoveLeadingUriScheme();
            result.Currency       = currency;
            result.DiscountAmount = new Money(lineItemDto.DiscountAmount ?? 0, currency);

            if (lineItemDto.DynamicProperties != null)
            {
                result.DynamicProperties = lineItemDto.DynamicProperties.Select(ToDynamicProperty).ToList();
            }
            result.Price                 = new Money(lineItemDto.Price ?? 0, currency);
            result.PriceWithTax          = new Money(lineItemDto.PriceWithTax ?? 0, currency);
            result.DiscountAmount        = new Money(lineItemDto.DiscountAmount ?? 0, currency);
            result.DiscountAmountWithTax = new Money(lineItemDto.DiscountAmountWithTax ?? 0, currency);
            result.PlacedPrice           = new Money(lineItemDto.PlacedPrice ?? 0, currency);
            result.PlacedPriceWithTax    = new Money(lineItemDto.PlacedPriceWithTax ?? 0, currency);
            result.ExtendedPrice         = new Money(lineItemDto.ExtendedPrice ?? 0, currency);
            result.ExtendedPriceWithTax  = new Money(lineItemDto.ExtendedPriceWithTax ?? 0, currency);
            result.DiscountTotal         = new Money(lineItemDto.DiscountTotal ?? 0, currency);
            result.DiscountTotalWithTax  = new Money(lineItemDto.DiscountTotalWithTax ?? 0, currency);
            result.TaxTotal              = new Money(lineItemDto.TaxTotal ?? 0, currency);
            result.TaxPercentRate        = (decimal?)lineItemDto.TaxPercentRate ?? 0m;
            if (!lineItemDto.Discounts.IsNullOrEmpty())
            {
                result.Discounts.AddRange(lineItemDto.Discounts.Select(x => ToDiscount(x, new[] { currency }, language)));
            }
            if (lineItemDto.TaxDetails != null)
            {
                result.TaxDetails = lineItemDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }

            return(result);
        }
예제 #2
0
        public static LineItem ToOrderLineItem(this orderDto.LineItem lineItemDto, IEnumerable <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(lineItemDto.Currency)) ?? new Currency(language, lineItemDto.Currency);

            var result = new LineItem(currency)
            {
                CancelledDate      = lineItemDto.CancelledDate,
                CancelReason       = lineItemDto.CancelReason,
                CatalogId          = lineItemDto.CatalogId,
                CategoryId         = lineItemDto.CategoryId,
                Height             = lineItemDto.Height,
                Id                 = lineItemDto.Id,
                ImageUrl           = lineItemDto.ImageUrl,
                IsCancelled        = lineItemDto.IsCancelled,
                IsGift             = lineItemDto.IsGift,
                Length             = lineItemDto.Length,
                MeasureUnit        = lineItemDto.MeasureUnit,
                Name               = lineItemDto.Name,
                ProductId          = lineItemDto.ProductId,
                Quantity           = lineItemDto.Quantity,
                ReserveQuantity    = lineItemDto.ReserveQuantity,
                ShippingMethodCode = lineItemDto.ShippingMethodCode,
                Sku                = lineItemDto.Sku,
                TaxType            = lineItemDto.TaxType,
                Weight             = lineItemDto.Weight,
                WeightUnit         = lineItemDto.WeightUnit,
                Width              = lineItemDto.Width,
                CreatedBy          = lineItemDto.CreatedBy,
                CreatedDate        = lineItemDto.CreatedDate,
                ModifiedDate       = lineItemDto.ModifiedDate,
                ModifiedBy         = lineItemDto.ModifiedBy
            };


            result.ImageUrl       = result.ImageUrl.RemoveLeadingUriScheme();
            result.Currency       = currency;
            result.DiscountAmount = new Money(lineItemDto.DiscountAmount ?? 0, currency);

            if (lineItemDto.DynamicProperties != null)
            {
                result.DynamicProperties = lineItemDto.DynamicProperties.Select(ToDynamicProperty).ToList();
            }
            result.ListPrice             = new Money(lineItemDto.Price ?? 0, currency);
            result.ListPriceWithTax      = new Money(lineItemDto.PriceWithTax ?? 0, currency);
            result.DiscountAmount        = new Money(lineItemDto.DiscountAmount ?? 0, currency);
            result.DiscountAmountWithTax = new Money(lineItemDto.DiscountAmountWithTax ?? 0, currency);
            result.PlacedPrice           = new Money(lineItemDto.PlacedPrice ?? 0, currency);
            result.PlacedPriceWithTax    = new Money(lineItemDto.PlacedPriceWithTax ?? 0, currency);
            result.ExtendedPrice         = new Money(lineItemDto.ExtendedPrice ?? 0, currency);
            result.ExtendedPriceWithTax  = new Money(lineItemDto.ExtendedPriceWithTax ?? 0, currency);
            result.DiscountTotal         = new Money(lineItemDto.DiscountTotal ?? 0, currency);
            result.DiscountTotalWithTax  = new Money(lineItemDto.DiscountTotalWithTax ?? 0, currency);
            result.TaxTotal       = new Money(lineItemDto.TaxTotal ?? 0, currency);
            result.TaxPercentRate = (decimal?)lineItemDto.TaxPercentRate ?? 0m;
            if (!lineItemDto.Discounts.IsNullOrEmpty())
            {
                result.Discounts.AddRange(lineItemDto.Discounts.Select(x => ToDiscount(x, new[] { currency }, language)));
            }
            if (lineItemDto.TaxDetails != null)
            {
                result.TaxDetails = lineItemDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }

            return(result);
        }
예제 #3
0
 public static LineItem ToOrderLineItem(this orderDto.LineItem lineItemDto, IEnumerable <Currency> availCurrencies, Language language)
 {
     return(OrderConverterInstance.ToOrderLineItem(lineItemDto, availCurrencies, language));
 }