public IActionResult ShowSearchResults(string searchText)
        {
            NorthwindDb            db = new NorthwindDb(_connectionString);
            SearchResultsViewModel vm = new SearchResultsViewModel();

            vm.Products   = db.Search(searchText);
            vm.SearchText = searchText;
            return(View(vm));
        }
示例#2
0
        public ActionResult Index(string categoryName, int?minStock)
        {
            NorthwindDb           db       = new NorthwindDb(Properties.Settings.Default.ConStr);
            IEnumerable <Product> products = db.Search(categoryName, minStock);
            HomePageViewModel     vm       = new HomePageViewModel();

            vm.Products        = products;
            vm.CategoryName    = categoryName;
            vm.MinUnitsInStock = minStock;
            return(View(vm));
        }
示例#3
0
        static void Main(string[] args)
        {
            NorthwindDb           db       = new NorthwindDb(Properties.Settings.Default.ConStr);
            IEnumerable <Product> products = db.Search("Beverages", 50);

            products.ToList().ForEach(p =>
            {
                Console.WriteLine($"{p.Name} - {p.CategoryName} - {p.UnitsInStock}");
            });

            Console.ReadKey(true);
        }
示例#4
0
        public ActionResult SearchResults(int min, int max)
        {
            NorthwindDb            db       = new NorthwindDb(_connectionString);
            List <Product>         products = db.Search(min, max);
            SearchResultsViewModel vm       = new SearchResultsViewModel
            {
                Products = products,
                Min      = min,
                Max      = max
            };

            return(View(vm));
        }