Esempio n. 1
0
        public PackingSlipViewModel(PackingListDTO order, int number)
        {
            Number            = number;
            BatchNumber       = order.BatchId.HasValue ? (int)order.BatchId.Value : 0;
            AddressToFullName = order.FinalPersonName;
            AddressToPhone    = order.FinalShippingPhone;

            AddressToAddress1 = order.FinalShippingAddress1;
            AddressToAddress2 = order.FinalShippingAddress2;
            AddressToCity     = order.FinalShippingCity;
            AddressToZip      = ShippingUtils.CombineZip(order.FinalShippingZip, order.FinalShippingZipAddon);
            AddressToState    = order.FinalShippingState;
            AddressToCountry  = order.FinalShippingCountry;

            OrderId       = order.OrderId;
            Market        = (MarketType)order.Market;
            MarketplaceId = order.MarketplaceId;

            PersonName = order.PersonName;
            BuyerName  = order.BuyerName;
            OrderDate  = order.OrderDate;

            Carrier = order.Carrier;
            if (order.StampsShippingCost == 0 || !order.StampsShippingCost.HasValue)
            {
                ShippingService = order.InitialServiceType;
            }
            else
            {
                ShippingService = order.ShippingMethodName;
            }

            Items = new List <PackingSlipItemViewModel>();
            foreach (var item in order.Items)
            {
                var image = item.ItemPicture;
                if (String.IsNullOrEmpty(image))
                {
                    image = item.StyleImage;
                }

                //TEMP: always style image
                //NOTE: Disabled, back to listing images
                //image = item.StyleImage;

                if (!String.IsNullOrEmpty(item.StyleImage) &&
                    item.SourceStyleString != item.StyleID)
                {
                    //NOTE: happens when item has linked style OR item style was changed
                    image = item.StyleImage;
                }

                if (item.UseStyleImage)
                {
                    image = item.StyleImage;
                }

                Items.Add(new PackingSlipItemViewModel
                {
                    ASIN = item.ASIN,

                    ImageUrl    = ImageHelper.GetFirstOrDefaultPicture(image),
                    Quantity    = item.QuantityOrdered,
                    ListingID   = item.ListingId,
                    Name        = item.Title,
                    OrderItemID = item.ItemOrderId,
                    Size        = item.Size,
                    Color       = item.Color,
                    SKU         = item.SKU,
                    StyleID     = item.StyleID,

                    StyleSize  = item.StyleSize,
                    StyleColor = item.StyleColor,

                    Isle    = item.DefaultLocation?.Isle,
                    Section = item.DefaultLocation?.Section,
                    Shelf   = item.DefaultLocation?.Shelf
                });
            }
        }