Esempio n. 1
0
        public ActionResult AddToSharedCart(int id, ShoppingCart cart)
        {
            AddItemModel model = new AddItemModel();

            ViewBag.canAdd  = string.IsNullOrEmpty(cart.CartKey) ? "n" : "y";
            model.Product   = ProductRepository.GetProductById(id);
            model.ProductID = id;
            List <ProductSize> lps = ProductSizeRepository.GetProductSizesByProductId(true, id);

            model.SizeAssistances = new List <SelectListItem>();
            foreach (var s in lps)
            {
                model.SizeAssistances.Add(new SelectListItem {
                    Text = s.Title + string.Format(" {0}{1}", s.Size > 0 ? " " + s.Size + "\"" : "", " ($" + s.Price.ToString("N2") + ")"), Value = s.ProductSizeId.ToString()
                });
            }
            List <ProductTopping> lpt = new List <ProductTopping>();

            lpt = ProductToppingRepository.GetProductToppingsByProductId(true, id);
            foreach (var t in lpt)
            {
                model.ToppingAssistances.Add(new CheckBoxViewModel {
                    BoxName = t.ToppingTitle, BoxPrice = t.ExtraToppingPrice, Checked = false
                });
            }
            if (model.Product.MaxNumOfFreeTopping > 0)
            {
                foreach (var t in lpt)
                {
                    model.FreeToppingAssistances.Add(new CheckBoxViewModel {
                        BoxName = t.ToppingTitle, BoxPrice = t.ExtraToppingPrice, Checked = false
                    });
                }
            }
            List <AddSide> las = new List <AddSide>();

            las = model.Product.AddSides.Where(e => e.Active == true).ToList();
            foreach (var a in las)
            {
                model.AddSideAssistances.Add(new AddSideCheckBoxModel {
                    BoxName = a.Title, BoxPrice = a.Price, BoxBizPrice = a.BizPrice, Checked = false
                });
            }
            SharedShoppingCart ssc = new SharedShoppingCart();

            if (string.IsNullOrEmpty(cart.CartKey) == false)
            {
                ssc = GetGroupShoppingCart(cart.CartKey);
            }
            model.SharedCart = ssc;
            model.Cart       = cart;
            return(PartialView(model));
        }
Esempio n. 2
0
        public ActionResult AddToCart(int id)
        {
            AddItemModel model = new AddItemModel();

            model.Product   = ProductRepository.GetProductById(id);
            model.ProductID = id;
            List <ProductSize> lps = ProductSizeRepository.GetProductSizesByProductId(true, id);

            model.SizeAssistances = new List <SelectListItem>();
            foreach (var s in lps)
            {
                model.SizeAssistances.Add(new SelectListItem {
                    Text = s.Title + string.Format(" {0}{1}", s.Size > 0 ? " " + s.Size + "\"" : "", " ($" + s.Price.ToString("N2") + ")"), Value = s.ProductSizeId.ToString()
                });
            }
            List <ProductTopping> lpt = new List <ProductTopping>();

            lpt = ProductToppingRepository.GetProductToppingsByProductId(true, id);
            foreach (var t in lpt)
            {
                model.ToppingAssistances.Add(new CheckBoxViewModel {
                    BoxName = t.ToppingTitle, BoxPrice = t.ExtraToppingPrice, BoxIncrementValue = t.Increment, Checked = false
                });
            }
            if (model.Product.MaxNumOfFreeTopping > 0)
            {
                foreach (var t in lpt)
                {
                    model.FreeToppingAssistances.Add(new CheckBoxViewModel {
                        BoxName = t.ToppingTitle, BoxPrice = t.ExtraToppingPrice, Checked = false
                    });
                }
            }
            List <AddSide> las = new List <AddSide>();

            las = model.Product.AddSides.Where(e => e.Active == true).ToList();
            foreach (var a in las)
            {
                model.AddSideAssistances.Add(new AddSideCheckBoxModel {
                    BoxName = a.Title, BoxPrice = a.Price, BoxBizPrice = a.BizPrice, Checked = false
                });
            }
            return(PartialView(model));
        }
Esempio n. 3
0
 public async Task <IActionResult> GetProductSizes(int id)
 {
     return(Ok(await _repo.GetProductSizesByProductId(id)));
 }