Beispiel #1
0
 public OpenBoxViewModel(OpenBoxDto item,
                         StyleEntireDto style,
                         IList <StyleItemDTO> styleItems,
                         List <OpenBoxItemDto> boxItems)
 {
     ConstructFrom(item, style, styleItems, boxItems);
 }
Beispiel #2
0
 public OpenBoxViewModel(IUnitOfWork db,
                         OpenBoxDto item,
                         StyleEntireDto style,
                         IList <StyleItemDTO> styleItems,
                         List <OpenBoxItemDto> boxItems,
                         List <OpenBoxTrackingDTO> boxTrackings)
 {
     ConstructFrom(db, item, style, styleItems, boxItems, boxTrackings);
 }
Beispiel #3
0
        private void ConstructFrom(IUnitOfWork db,
                                   OpenBoxDto item,
                                   StyleEntireDto style,
                                   IList <StyleItemDTO> styleItems,
                                   List <OpenBoxItemDto> boxItems,
                                   List <OpenBoxTrackingDTO> boxTrackings)
        {
            Id      = item.Id;
            StyleId = item.StyleId;

            if (style != null)
            {
                StyleString = style.StyleID;
            }

            Type = item.Type;

            BoxBarcode  = item.BoxBarcode;
            Printed     = item.Printed;
            PolyBags    = item.PolyBags;
            BoxQuantity = item.BoxQuantity;
            Price       = item.Price;
            Owned       = item.Owned;
            Archived    = item.Archived;

            CreateDate = item.CreateDate;
            UpdateDate = item.UpdateDate;

            UpdatedByName = item.UpdatedByName;

            SizesQuantity = boxItems.Sum(s => s.Quantity);

            StyleItems = new StyleItemCollection()
            {
                DisplayMode = StyleItemDisplayMode.BoxQty,
                Items       = styleItems
                              .OrderBy(si => SizeHelper.GetSizeIndex(si.Size))
                              .ThenBy(si => si.Color)
                              .Select(si => new StyleItemViewModel(si))
                              .ToList()
            };

            //Set boxes values
            foreach (var boxItem in boxItems)
            {
                var styleItem = StyleItems.Items.FirstOrDefault(si => si.Id == boxItem.StyleItemId);
                if (styleItem != null)
                {
                    styleItem.Quantity  = boxItem.Quantity;
                    styleItem.BoxItemId = boxItem.Id;
                }
            }
        }