Esempio n. 1
0
        public IActionResult ProductCategory(string selectedCategory)
        {
            Category category;

            if (selectedCategory == "Sedan")
            {
                category = Category.Sedan;
            }
            else if (selectedCategory == "Suv")
            {
                category = Category.Suv;
            }
            else if (selectedCategory == "Sport")
            {
                category = Category.Sport;
            }
            else
            {
                category = Category.Minivan;
            }
            IQueryable <Car> cars = from m in _context.Cars select m;


            CarHouseViewModel carViewModel = new CarHouseViewModel
            {
                Cars = cars.Where(x => x.Category == category).ToList()
            };

            return(View(carViewModel));
        }
Esempio n. 2
0
        public IActionResult Products()
        {
            ViewData["Title"] = "Home Page";
            CarHouseViewModel carViewModel = new CarHouseViewModel
            {
                Cars = _context.Cars.ToList()
            };

            return(View(carViewModel));
        }