Ejemplo n.º 1
0
        public virtual Shipment ToOrderShipment(orderDto.Shipment shipmentDto, ICollection <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(shipmentDto.Currency)) ?? new Currency(language, shipmentDto.Currency);
            var result   = new Shipment(currency);

            result.InjectFrom <NullableAndEnumValueInjecter>(shipmentDto);

            result.Currency = currency;

            if (shipmentDto.DeliveryAddress != null)
            {
                result.DeliveryAddress = ToAddress(shipmentDto.DeliveryAddress);
            }

            if (!shipmentDto.Discounts.IsNullOrEmpty())
            {
                result.Discounts.AddRange(shipmentDto.Discounts.Select(x => ToDiscount(x, new[] { currency }, language)));
            }

            if (shipmentDto.DynamicProperties != null)
            {
                result.DynamicProperties = shipmentDto.DynamicProperties.Select(ToDynamicProperty).ToList();
            }

            if (shipmentDto.InPayments != null)
            {
                result.InPayments = shipmentDto.InPayments.Select(p => ToOrderInPayment(p, availCurrencies, language)).ToList();
            }

            if (shipmentDto.Items != null)
            {
                result.Items = shipmentDto.Items.Select(i => ToShipmentItem(i, availCurrencies, language)).ToList();
            }

            if (shipmentDto.Packages != null)
            {
                result.Packages = shipmentDto.Packages.Select(p => ToShipmentPackage(p, availCurrencies, language)).ToList();
            }

            result.Price                 = new Money(shipmentDto.Price ?? 0, currency);
            result.PriceWithTax          = new Money(shipmentDto.PriceWithTax ?? 0, currency);
            result.DiscountAmount        = new Money(shipmentDto.DiscountAmount ?? 0, currency);
            result.DiscountAmountWithTax = new Money(shipmentDto.DiscountAmountWithTax ?? 0, currency);
            result.Total                 = new Money(shipmentDto.Total ?? 0, currency);
            result.TotalWithTax          = new Money(shipmentDto.TotalWithTax ?? 0, currency);
            result.TaxTotal              = new Money(shipmentDto.TaxTotal ?? 0, currency);
            result.TaxPercentRate        = (decimal?)shipmentDto.TaxPercentRate ?? 0m;
            if (shipmentDto.TaxDetails != null)
            {
                result.TaxDetails = shipmentDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static Shipment ToOrderShipment(this orderDto.Shipment shipmentDto, IEnumerable <Currency> availCurrencies, Language language)
        {
            var currency = availCurrencies.FirstOrDefault(x => x.Equals(shipmentDto.Currency)) ?? new Currency(language, shipmentDto.Currency);
            var result   = new Shipment(currency)
            {
                CancelledDate         = shipmentDto.CancelledDate,
                CancelReason          = shipmentDto.CancelReason,
                Comment               = shipmentDto.Comment,
                EmployeeId            = shipmentDto.EmployeeId,
                EmployeeName          = shipmentDto.EmployeeName,
                FulfillmentCenterId   = shipmentDto.FulfillmentCenterId,
                FulfillmentCenterName = shipmentDto.FulfillmentCenterName,
                Height               = shipmentDto.Height,
                Id                   = shipmentDto.Id,
                Length               = shipmentDto.Length,
                MeasureUnit          = shipmentDto.MeasureUnit,
                Number               = shipmentDto.Number,
                OperationType        = shipmentDto.OperationType,
                OrganizationId       = shipmentDto.OrganizationId,
                OrganizationName     = shipmentDto.OrganizationName,
                ShipmentMethodCode   = shipmentDto.ShipmentMethodCode,
                ShipmentMethodOption = shipmentDto.ShipmentMethodOption,
                Status               = shipmentDto.Status,
                TaxType              = shipmentDto.TaxType,
                Weight               = shipmentDto.Weight,
                WeightUnit           = shipmentDto.WeightUnit,
                Width                = shipmentDto.Width,
                Currency             = currency,
                CreatedBy            = shipmentDto.CreatedBy,
                CreatedDate          = shipmentDto.CreatedDate,
                ModifiedDate         = shipmentDto.ModifiedDate,
                ModifiedBy           = shipmentDto.ModifiedBy,
            };

            if (shipmentDto.DeliveryAddress != null)
            {
                result.DeliveryAddress = ToAddress(shipmentDto.DeliveryAddress);
            }

            if (!shipmentDto.Discounts.IsNullOrEmpty())
            {
                result.Discounts.AddRange(shipmentDto.Discounts.Select(x => ToDiscount(x, new[] { currency }, language)));
            }

            if (shipmentDto.DynamicProperties != null)
            {
                result.DynamicProperties = shipmentDto.DynamicProperties.Select(ToDynamicProperty).ToList();
            }

            if (shipmentDto.InPayments != null)
            {
                result.InPayments = shipmentDto.InPayments.Select(p => ToOrderInPayment(p, availCurrencies, language)).ToList();
            }

            if (shipmentDto.Items != null)
            {
                result.Items = shipmentDto.Items.Select(i => ToShipmentItem(i, availCurrencies, language)).ToList();
            }

            if (shipmentDto.Packages != null)
            {
                result.Packages = shipmentDto.Packages.Select(p => ToShipmentPackage(p, availCurrencies, language)).ToList();
            }

            result.Price                 = new Money(shipmentDto.Price ?? 0, currency);
            result.PriceWithTax          = new Money(shipmentDto.PriceWithTax ?? 0, currency);
            result.DiscountAmount        = new Money(shipmentDto.DiscountAmount ?? 0, currency);
            result.DiscountAmountWithTax = new Money(shipmentDto.DiscountAmountWithTax ?? 0, currency);
            result.Total                 = new Money(shipmentDto.Total ?? 0, currency);
            result.TotalWithTax          = new Money(shipmentDto.TotalWithTax ?? 0, currency);
            result.TaxTotal              = new Money(shipmentDto.TaxTotal ?? 0, currency);
            result.TaxPercentRate        = (decimal?)shipmentDto.TaxPercentRate ?? 0m;
            if (shipmentDto.TaxDetails != null)
            {
                result.TaxDetails = shipmentDto.TaxDetails.Select(td => ToTaxDetail(td, currency)).ToList();
            }
            return(result);
        }
Ejemplo n.º 3
0
 public static Model.Order.Shipment ToOrderShipment(this orderDto.Shipment shipmentDto, ICollection <Currency> availCurrencies, Language language)
 {
     return(OrderConverterInstance.ToOrderShipment(shipmentDto, availCurrencies, language));
 }