示例#1
0
        public CartModel Build(Cart sessionCart)
        {
            var u     = AccountAdminModelBuilder.BuildOneUser(WebSecurity.CurrentUserName);
            var model = new CartModel();

            model.cart = sessionCart;
            foreach (var cartItem in sessionCart.listSku)
            {
                var sku = dataService.GetSkuById(cartItem.idSku);
                if (u != null && u.Discount > 0)
                {
                    sku.priceAct = sku.priceAct - ((sku.priceAct / 100) * u.Discount);
                }
                sku.smalPhoto.path = string.Format("{0}/{1}", imagesPath.GetImagesPath(), sku.smalPhoto.path);
                model.listSku.Add(sku);
            }

            foreach (var cartItem in model.cart.listSku)
            {
                var tmpSku = model.listSku.First(i => i.id == cartItem.idSku);
                cartItem.priceAct = tmpSku.priceAct;
            }

            model.menu      = BuildMenu();
            model.listState = dataService.ListCartState();
            return(model);
        }
示例#2
0
        private IEnumerable <ShortSKUModel> ListSkuByCategory(StaticCategory cat)
        {
            var u = AccountAdminModelBuilder.BuildOneUser(WebSecurity.CurrentUserName);

            if (u != null && u.Discount > 0)
            {
                return(dataService.ListSkuByCategory(cat).Select(sku => new ShortSKUModel()
                {
                    id = sku.id,
                    brandId = sku.brand.id,
                    brandName = sku.brand.name,
                    categotyId = cat.id,
                    categotyName = cat.name,
                    description = sku.description,
                    name = sku.name,
                    price = sku.price,
                    priceAct = sku.priceAct - ((sku.priceAct / 100) * u.Discount),
                    smalPhotoPath = string.Format("{0}/{1}", imagesPath.GetImagesPath(), (sku.smalPhoto ?? new Photo()
                    {
                        path = "box.png"
                    }).path)
                }));
            }

            return(dataService.ListSkuByCategory(cat).Select(sku => new ShortSKUModel()
            {
                id = sku.id,
                brandId = sku.brand.id,
                brandName = sku.brand.name,
                categotyId = cat.id,
                categotyName = cat.name,
                description = sku.description,
                name = sku.name,
                price = sku.price,
                priceAct = sku.priceAct,
                smalPhotoPath = string.Format("{0}/{1}", imagesPath.GetImagesPath(), (sku.smalPhoto ?? new Photo()
                {
                    path = "box.png"
                }).path)
            }));
        }
示例#3
0
        public SKUModel ConvertSkuBDToSkuModel(Sku sku)
        {
            var u        = AccountAdminModelBuilder.BuildOneUser(WebSecurity.CurrentUserName);
            var skuModel = GetEmptySku();

            if (sku != null)
            {
                skuModel.id    = sku.id;
                skuModel.name  = sku.name;
                skuModel.price = sku.price;

                if (u != null && u.Discount > 0)
                {
                    skuModel.priceAct = sku.priceAct - ((sku.priceAct / 100) * u.Discount);
                }
                else
                {
                    skuModel.priceAct = sku.priceAct;
                }

                skuModel.priceAct = sku.priceAct;

                skuModel.description = sku.description;
                if (sku.brand != null)
                {
                    skuModel.brandId   = sku.brand.id;
                    skuModel.brandName = sku.brand.name;
                }

                if (sku.smalPhoto != null)
                {
                    skuModel.smalPhotoId   = sku.smalPhoto.id;
                    skuModel.smalPhotoPath = string.Format("{0}/{1}", imagesPath.GetImagesPath(), sku.smalPhoto.path);
                }

                skuModel.listCategory      = sku.listCategory;
                skuModel.listSpecification = sku.listSpecification;
                skuModel.listPhoto         = sku.listPhoto.Select(im => new PhotoBig()
                {
                    id = im.id, name = im.name, path = string.Format("{0}/{1}", imagesPath.GetImagesPath(), im.path), skuId = im.skuId
                }).ToList();
            }
            return(skuModel);
        }