示例#1
0
        public IActionResult Refresh()
        {
            var list = _listItemService.getAll().Result.Where(a => a.InCart == true);

            if (this.shoppingCart.ListItems.Count == 0)
            {
                this.shoppingCart.ListItems = list.ToList();
            }
            else
            {
                foreach (var itm in list)
                {
                    this.shoppingCart.ListItems.Add(itm);
                }
            }
            return(PartialView("_ShoppingCart", this.shoppingCart));
        }
示例#2
0
        public async Task <IActionResult> RemoveProductsInCart(int idShoppingList)
        {
            var listItems = _listItemService.getAll().Result.Where(p => p.InCart == true && p.ShoppingListId == idShoppingList);

            foreach (var listItem in listItems)
            {
                try
                {
                    listItem.InCart = false;
                    await _listItemService.Edit(listItem);
                }
                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
            }
            return(RedirectToAction("Index", "ShoppingLists"));
        }
示例#3
0
        public async Task <IActionResult> Index()
        {
            var list = await _listItemService.getAll();

            return(View(list.OrderBy(l => l.InCart ? 0 : 1).ThenBy(l => l.Product.Name)));
        }