Exemplo n.º 1
0
        public IActionResult Index()
        {
            // TODO ToList() is a workaround for:
            //        - https://github.com/aspnet/EntityFramework/issues/1851
            //        - https://github.com/aspnet/EntityFramework/issues/1852

            var products = db.Products
                           .ToList()
                           .OrderByDescending(p => p.MSRP - p.CurrentPrice)
                           .Take(4);

            return(View(new IndexViewModel
            {
                FeaturedProducts = products,
                TopLevelCategories = categoryCache.TopLevel()
            }));
        }
Exemplo n.º 2
0
        public IActionResult Index()
        {
            var ads = db.WebsiteAds
                      .Where(a => a.Start == null || a.Start <= DateTime.Now.ToUniversalTime())
                      .Where(a => a.End == null || a.End >= DateTime.Now.ToUniversalTime());

            return(View(new IndexViewModel
            {
                TopLevelCategories = categoryCache.TopLevel(),
                CurrentAds = ads.ToList()
            }));
        }
Exemplo n.º 3
0
        public IActionResult Index(IndexMessage message = IndexMessage.None)
        {
            var items = db.CartItems
                        .Where(i => i.Username == User.GetUserName())
                        .Include(i => i.Product)
                        .ToList();

            return(View(new IndexViewModel
            {
                CartItems = items,
                TopLevelCategories = categoryCache.TopLevel(),
                Message = message
            }));
        }