예제 #1
0
        private List<OrderPackageDTO> TranslatePackages(data.bvc_Order o)
        {
            List<OrderPackageDTO> result = new List<OrderPackageDTO>();

            foreach (data.bvc_Package item in o.bvc_Package)
            {
                OrderPackageDTO pak = new OrderPackageDTO();

                pak.CustomProperties = new List<CustomPropertyDTO>();
                pak.Description = string.Empty;
                pak.EstimatedShippingCost = (decimal)item.ShippingCost;
                pak.HasShipped = true;
                pak.Height = (decimal)item.Height;
                pak.Items = new List<OrderPackageItemDTO>();
                pak.LastUpdatedUtc = item.ShipDate ?? DateTime.UtcNow;
                pak.Length = (decimal)item.Length;
                pak.OrderId = o.ID.ToString();
                pak.ShipDateUtc = item.ShipDate ?? DateTime.UtcNow;
                pak.ShippingMethodId = string.Empty;
                pak.ShippingProviderId = string.Empty;
                pak.ShippingProviderServiceCode = item.ShippingServiceCode;
                pak.SizeUnits = LengthTypeDTO.Inches;
                pak.TrackingNumber = item.TrackingNumber;
                pak.Weight = (decimal)item.Weight;
                pak.WeightUnits = WeightTypeDTO.Pounds;
                pak.Width = (decimal)item.Width;
                result.Add(pak);
            }

            return result;
        }
예제 #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
        private List<OrderPackageDTO> TranslatePackages(string orderBvin)
        {
            List<OrderPackageDTO> result = new List<OrderPackageDTO>();

            data.BV53Entities db = new data.BV53Entities(EFConnString(settings.SourceConnectionString()));

            var old = db.bvc_OrderPackage.Where(y => y.OrderId == orderBvin);
            if (old == null) return result;

            foreach (data.bvc_OrderPackage item in old)
            {
                OrderPackageDTO pak = new OrderPackageDTO();

                pak.CustomProperties = TranslateOldProperties(item.CustomProperties);
                pak.Description = item.Description ?? string.Empty;
                pak.EstimatedShippingCost = item.EstimatedShippingCost;
                pak.HasShipped = item.HasShipped == 1;
                pak.Height = item.Height;
                pak.Items = TranslateOldPackageItems(item.Items);
                pak.LastUpdatedUtc = item.LastUpdated;
                pak.Length = item.Length;
                pak.OrderId = orderBvin;
                pak.ShipDateUtc = item.ShipDate;
                pak.ShippingMethodId = string.Empty;
                pak.ShippingProviderId = item.ShippingProviderId;
                pak.ShippingProviderServiceCode = item.ShippingProviderServiceCode;
                pak.SizeUnits = LengthTypeDTO.Inches;
                if (item.SizeUnits == 2)
                {
                    pak.SizeUnits = LengthTypeDTO.Centimeters;
                }
                pak.TrackingNumber = item.TrackingNumber;
                pak.Weight = item.Weight;
                pak.WeightUnits = WeightTypeDTO.Pounds;
                if (item.WeightUnits == 2)
                {
                    pak.WeightUnits = WeightTypeDTO.Kilograms;
                }
                pak.Width = item.Width;
                result.Add(pak);
            }

            return result;
        }
예제 #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;
        }