Exemple #1
0
        public static cartDto.CartLineItem ToLineItemDto(this LineItem lineItem)
        {
            var retVal = new cartDto.CartLineItem
            {
                Id                 = lineItem.Id,
                IsReadOnly         = lineItem.IsReadOnly,
                CatalogId          = lineItem.CatalogId,
                CategoryId         = lineItem.CategoryId,
                ImageUrl           = lineItem.ImageUrl,
                Name               = lineItem.Name,
                ProductId          = lineItem.ProductId,
                ProductType        = lineItem.ProductType,
                Quantity           = lineItem.Quantity,
                ShipmentMethodCode = lineItem.ShipmentMethodCode,
                Sku                = lineItem.Sku,
                TaxType            = lineItem.TaxType,
                ThumbnailImageUrl  = lineItem.ThumbnailImageUrl,
                WeightUnit         = lineItem.WeightUnit,
                MeasureUnit        = lineItem.MeasureUnit,
                Weight             = (double?)lineItem.Weight,
                Width              = (double?)lineItem.Width,
                Length             = (double?)lineItem.Length,
                Height             = (double?)lineItem.Height,
                Note               = lineItem.Comment,

                Currency  = lineItem.Currency.Code,
                Discounts = lineItem.Discounts.Select(ToCartDiscountDto).ToList(),

                ListPrice         = (double)lineItem.ListPrice.InternalAmount,
                SalePrice         = (double)lineItem.SalePrice.InternalAmount,
                TaxPercentRate    = (double)lineItem.TaxPercentRate,
                DiscountAmount    = (double)lineItem.DiscountAmount.InternalAmount,
                TaxDetails        = lineItem.TaxDetails.Select(ToCartTaxDetailDto).ToList(),
                DynamicProperties = lineItem.DynamicProperties.Select(ToCartDynamicPropertyDto).ToList(),
                VolumetricWeight  = (double)(lineItem.VolumetricWeight ?? 0),

                ConfiguredGroupId = lineItem.ConfiguredGroupId,
            };

            retVal.Weight = (double?)lineItem.Weight;
            retVal.Width  = (double?)lineItem.Width;
            retVal.Height = (double?)lineItem.Height;
            retVal.Length = (double?)lineItem.Length;

            return(retVal);
        }
Exemple #2
0
        public static LineItem ToLineItem(this cartDto.CartLineItem lineItemDto, Currency currency, Language language)
        {
            var result = new LineItem(currency, language)
            {
                Id                 = lineItemDto.Id,
                IsReadOnly         = lineItemDto.IsReadOnly ?? false,
                CatalogId          = lineItemDto.CatalogId,
                CategoryId         = lineItemDto.CategoryId,
                ImageUrl           = lineItemDto.ImageUrl,
                Name               = lineItemDto.Name,
                ObjectType         = lineItemDto.ObjectType,
                ProductId          = lineItemDto.ProductId,
                ProductType        = lineItemDto.ProductType,
                Quantity           = lineItemDto.Quantity ?? 1,
                ShipmentMethodCode = lineItemDto.ShipmentMethodCode,
                Sku                = lineItemDto.Sku,
                TaxType            = lineItemDto.TaxType,
                ThumbnailImageUrl  = lineItemDto.ThumbnailImageUrl,
                WeightUnit         = lineItemDto.WeightUnit,
                MeasureUnit        = lineItemDto.MeasureUnit,
                Weight             = (decimal?)lineItemDto.Weight,
                Width              = (decimal?)lineItemDto.Width,
                Length             = (decimal?)lineItemDto.Length,
                Height             = (decimal?)lineItemDto.Height,
                ConfiguredGroupId  = lineItemDto.ConfiguredGroupId,
            };

            result.ImageUrl = lineItemDto.ImageUrl.RemoveLeadingUriScheme();

            if (lineItemDto.TaxDetails != null)
            {
                result.TaxDetails = lineItemDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }

            if (lineItemDto.DynamicProperties != null)
            {
                result.DynamicProperties = new MutablePagedList <DynamicProperty>(lineItemDto.DynamicProperties.Select(ToDynamicProperty).ToList());
            }

            if (!lineItemDto.Discounts.IsNullOrEmpty())
            {
                result.Discounts.AddRange(lineItemDto.Discounts.Select(x => ToDiscount(x, new[] { currency }, language)));
            }
            result.Comment          = lineItemDto.Note;
            result.IsGift           = lineItemDto.IsGift == true;
            result.IsReccuring      = lineItemDto.IsReccuring == true;
            result.ListPrice        = new Money(lineItemDto.ListPrice ?? 0, currency);
            result.RequiredShipping = lineItemDto.RequiredShipping == true;
            result.SalePrice        = new Money(lineItemDto.SalePrice ?? 0, currency);
            result.TaxPercentRate   = (decimal?)lineItemDto.TaxPercentRate ?? 0m;
            result.DiscountAmount   = new Money(lineItemDto.DiscountAmount ?? 0, currency);
            result.TaxIncluded      = lineItemDto.TaxIncluded == true;
            result.Weight           = (decimal?)lineItemDto.Weight;
            result.Width            = (decimal?)lineItemDto.Width;
            result.Height           = (decimal?)lineItemDto.Height;
            result.Length           = (decimal?)lineItemDto.Length;


            result.DiscountAmountWithTax = new Money(lineItemDto.DiscountAmountWithTax ?? 0, currency);
            result.DiscountTotal         = new Money(lineItemDto.DiscountTotal ?? 0, currency);
            result.DiscountTotalWithTax  = new Money(lineItemDto.DiscountTotalWithTax ?? 0, currency);
            result.ListPriceWithTax      = new Money(lineItemDto.ListPriceWithTax ?? 0, currency);
            result.SalePriceWithTax      = new Money(lineItemDto.SalePriceWithTax ?? 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.TaxTotal = new Money(lineItemDto.TaxTotal ?? 0, currency);

            return(result);
        }