Ejemplo n.º 1
0
        public static OpenBoxViewModel BuildFromStyleId(IUnitOfWork db, long styleId)
        {
            var model = new OpenBoxViewModel();

            var style = db.Styles.GetByStyleIdAsDto(styleId);

            model.StyleString = style.StyleID;

            model.StyleId = styleId;

            model.Price       = db.OpenBoxes.GetByStyleId(styleId).OrderBy(b => b.Id).Select(b => b.Price).FirstOrDefault();
            model.BoxQuantity = 1;
            model.Owned       = true;

            var styleItems = db.StyleItems.GetByStyleIdWithSizeGroupAsDto(styleId).ToList();

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

            model.CreateDate = DateHelper.GetAppNowTime().Date;

            model.BoxBarcode = db.OpenBoxes.GetDefaultBoxName(styleId, model.CreateDate.Value);

            return(model);
        }
Ejemplo n.º 2
0
        public static OpenBoxViewModel BuildFromBoxId(IUnitOfWork db,
                                                      long openBoxId)
        {
            var model = new OpenBoxViewModel();

            var item = db.OpenBoxes.GetAllAsDto().FirstOrDefault(o => o.Id == openBoxId);

            var styleItems   = db.StyleItems.GetByStyleIdWithSizeGroupAsDto(item.StyleId).ToList();
            var boxSizeItems = db.OpenBoxItems.GetByBoxIdAsDto(openBoxId).ToList();
            var style        = db.Styles.GetByStyleIdAsDto(item.StyleId);

            model.ConstructFrom(item, style, styleItems, boxSizeItems);

            return(model);
        }