Example #1
0
        /// <summary>
        ///   Copies the eCommerce recipient to a new order recipient instance.
        /// </summary>
        ///
        /// <param name="source">The source of data for the new instance.</param>
        ///
        /// <returns>The new recipient instance, populated from the <paramref name="source" /></returns>
        ///
        private static OrderProduction.Recipient CopyRecipientToNewRecipient(eCommerce.Recipient source)
        {
            var recipient = new OrderProduction.Recipient();

            if (source == null)
            {
                return(recipient);
            }

            recipient.Id           = source.Id;
            recipient.LanguageCode = source.LanguageCode;
            recipient.Shipping     = OrderDetailsExtensions.CopyShippingInformationToNewShippingInformation(source.Shipping);
            recipient.OrderedItems = source.OrderedItems.Select(item => new OrderProduction.OrderItemDetails {
                Quantity = item.Quantity, LineItemId = item.LineItemId
            }).ToList();

            return(recipient);
        }
Example #2
0
        /// <summary>
        ///   Creates a new <see cref="CreateOrderMessage" /> based on the specified
        ///   <paramref name="instance"/>.
        /// </summary>
        ///
        /// <param name="instance">The instance that this method was invoked on.</param>
        ///
        /// <returns>A CreateOrderMessage materialzied with data sourced from the order details. </returns>
        ///
        public static CreateOrderMessage ToCreateOrderMessage(this OrderDetails instance)
        {
            var createOrderMessage = new CreateOrderMessage();

            if (instance == null)
            {
                return(createOrderMessage);
            }

            // Copy properties from the root of the details.

            createOrderMessage.Identity = new OrderIdentity {
                PartnerOrderId = instance.OrderId
            };
            createOrderMessage.Customer = new Customer {
                Code = instance.UserId, LanguageCode = instance.Recipients.FirstOrDefault()?.LanguageCode
            };
            createOrderMessage.Shipping     = new OrderShippingInformation();
            createOrderMessage.Instructions = new OrderInstructions();
            createOrderMessage.Recipients   = instance.Recipients.Select(recipient => OrderDetailsExtensions.CopyRecipientToNewRecipient(recipient)).ToList();
            createOrderMessage.LineItems    = instance.LineItems.Select(item => OrderDetailsExtensions.CopyLineItemToNewLineItem(item)).ToList();

            return(createOrderMessage);
        }