コード例 #1
0
        public IActionResult Index()
        {
            var basketId      = 1; // Use constant basket Id for demo. Could be fetched from the DB for the particular User or created and stored in Session.
            var products      = _supermarketRepository.GetAllProducts().ToList();
            var basketCount   = _supermarketRepository.GetBasketItemsCount(basketId);
            var homeViewModel = new HomeViewModel {
                Title            = "Welcome to Richie's Discount Supermarket",
                Products         = products, BasketId = basketId,
                BasketItemsCount = basketCount
            };

            return(View(homeViewModel));
        }