示例#1
0
        /// <summary>
        ///     Allows you to populate the current order package object using a OrderPackageDTO instance
        /// </summary>
        /// <param name="dto">An instance of the order package from the REST API</param>
        public void FromDto(OrderPackageDTO dto)
        {
            if (dto == null)
            {
                return;
            }

            if (dto.CustomProperties != null)
            {
                CustomProperties.Clear();
                foreach (var prop in dto.CustomProperties)
                {
                    var p = new CustomProperty();
                    p.FromDto(prop);
                    CustomProperties.Add(p);
                }
            }
            Description           = dto.Description ?? string.Empty;
            EstimatedShippingCost = dto.EstimatedShippingCost;
            HasShipped            = dto.HasShipped;
            Height = dto.Height;
            Id     = dto.Id;
            if (dto.Items != null)
            {
                Items.Clear();
                foreach (var item in dto.Items)
                {
                    var pak = new OrderPackageItem();
                    pak.FromDto(item);
                    Items.Add(pak);
                }
            }
            LastUpdatedUtc              = dto.LastUpdatedUtc;
            Length                      = dto.Length;
            OrderId                     = dto.OrderId ?? string.Empty;
            ShipDateUtc                 = dto.ShipDateUtc;
            ShippingMethodId            = dto.ShippingMethodId ?? string.Empty;
            ShippingProviderId          = dto.ShippingProviderId ?? string.Empty;
            ShippingProviderServiceCode = dto.ShippingProviderServiceCode ?? string.Empty;
            SizeUnits                   = (LengthType)(int)dto.SizeUnits;
            StoreId                     = dto.StoreId;
            TrackingNumber              = dto.TrackingNumber ?? string.Empty;
            Weight                      = dto.Weight;
            WeightUnits                 = (WeightType)(int)dto.WeightUnits;
            Width = dto.Width;
        }
示例#2
0
        public void FromDto(OrderPackageDTO dto)
        {
            if (dto == null)
            {
                return;
            }

            if (dto.CustomProperties != null)
            {
                this.CustomProperties.Clear();
                foreach (CustomPropertyDTO prop in dto.CustomProperties)
                {
                    CustomProperty p = new CustomProperty();
                    p.FromDto(prop);
                    this.CustomProperties.Add(p);
                }
            }
            this.Description           = dto.Description ?? string.Empty;
            this.EstimatedShippingCost = dto.EstimatedShippingCost;
            this.HasShipped            = dto.HasShipped;
            this.Height = dto.Height;
            this.Id     = dto.Id;
            if (dto.Items != null)
            {
                this.Items.Clear();
                foreach (OrderPackageItemDTO item in dto.Items)
                {
                    OrderPackageItem pak = new OrderPackageItem();
                    pak.FromDto(item);
                    this.Items.Add(pak);
                }
            }
            this.LastUpdatedUtc              = dto.LastUpdatedUtc;
            this.Length                      = dto.Length;
            this.OrderId                     = dto.OrderId ?? string.Empty;
            this.ShipDateUtc                 = dto.ShipDateUtc;
            this.ShippingMethodId            = dto.ShippingMethodId ?? string.Empty;
            this.ShippingProviderId          = dto.ShippingProviderId ?? string.Empty;
            this.ShippingProviderServiceCode = dto.ShippingProviderServiceCode ?? string.Empty;
            this.SizeUnits                   = (MerchantTribe.Shipping.LengthType)((int)dto.SizeUnits);
            this.StoreId                     = dto.StoreId;
            this.TrackingNumber              = dto.TrackingNumber ?? string.Empty;
            this.Weight                      = dto.Weight;
            this.WeightUnits                 = (MerchantTribe.Shipping.WeightType)((int)dto.WeightUnits);
            this.Width = dto.Width;
        }
示例#3
0
        /// <summary>
        ///     Allows you to convert the current order package object to the DTO equivalent for use with the REST API
        /// </summary>
        /// <returns>A new instance of OrderPackageDTO</returns>
        public OrderPackageDTO ToDto()
        {
            var dto = new OrderPackageDTO();

            dto.CustomProperties = new List <CustomPropertyDTO>();
            foreach (var prop in CustomProperties)
            {
                dto.CustomProperties.Add(prop.ToDto());
            }
            dto.Description           = Description ?? string.Empty;
            dto.EstimatedShippingCost = EstimatedShippingCost;
            dto.HasShipped            = HasShipped;
            dto.Height = Height;
            dto.Id     = Id;
            dto.Items  = new List <OrderPackageItemDTO>();
            {
                foreach (var item in Items)
                {
                    dto.Items.Add(item.ToDto());
                }
            }
            dto.LastUpdatedUtc              = LastUpdatedUtc;
            dto.Length                      = Length;
            dto.OrderId                     = OrderId ?? string.Empty;
            dto.ShipDateUtc                 = ShipDateUtc;
            dto.ShippingMethodId            = ShippingMethodId ?? string.Empty;
            dto.ShippingProviderId          = ShippingProviderId ?? string.Empty;
            dto.ShippingProviderServiceCode = ShippingProviderServiceCode ?? string.Empty;
            dto.SizeUnits                   = (LengthTypeDTO)(int)SizeUnits;
            dto.StoreId                     = StoreId;
            dto.TrackingNumber              = TrackingNumber ?? string.Empty;
            dto.Weight                      = Weight;
            dto.WeightUnits                 = (WeightTypeDTO)(int)WeightUnits;
            dto.Width = Width;

            return(dto);
        }
示例#4
0
        // DTO
        public OrderPackageDTO ToDto()
        {
            OrderPackageDTO dto = new OrderPackageDTO();

            dto.CustomProperties = new List <CommerceDTO.v1.CustomPropertyDTO>();
            foreach (CustomProperty prop in this.CustomProperties)
            {
                dto.CustomProperties.Add(prop.ToDto());
            }
            dto.Description           = this.Description ?? string.Empty;
            dto.EstimatedShippingCost = this.EstimatedShippingCost;
            dto.HasShipped            = this.HasShipped;
            dto.Height = this.Height;
            dto.Id     = this.Id;
            dto.Items  = new List <OrderPackageItemDTO>();
            {
                foreach (OrderPackageItem item in this.Items)
                {
                    dto.Items.Add(item.ToDto());
                }
            }
            dto.LastUpdatedUtc              = this.LastUpdatedUtc;
            dto.Length                      = this.Length;
            dto.OrderId                     = this.OrderId ?? string.Empty;
            dto.ShipDateUtc                 = this.ShipDateUtc;
            dto.ShippingMethodId            = this.ShippingMethodId ?? string.Empty;
            dto.ShippingProviderId          = this.ShippingProviderId ?? string.Empty;
            dto.ShippingProviderServiceCode = this.ShippingProviderServiceCode ?? string.Empty;
            dto.SizeUnits                   = (LengthTypeDTO)((int)this.SizeUnits);
            dto.StoreId                     = this.StoreId;
            dto.TrackingNumber              = this.TrackingNumber ?? string.Empty;
            dto.Weight                      = this.Weight;
            dto.WeightUnits                 = (WeightTypeDTO)((int)this.WeightUnits);
            dto.Width = this.Width;

            return(dto);
        }