Esempio n. 1
0
        public ActionResult Search(string keyword)
        {
            //var products = db.Products.Where(c => c.IsDeleted == false &&
            //    c.Name.Contains(keyword)
            //    ).ToList();

            var search_result = db.Search(keyword).ToList();

            List <Product> products = new List <Product>();

            foreach (var item in search_result)
            {
                var product = new Product();
                product.Id   = item.Id;
                product.Name = item.Name;

                products.Add(product);
            }

            return(View("Index", products));
        }
        public ActionResult Search(string keyword)
        {
            //var categories = db.Categories.Where(c => c.IsDeleted == false &&
            //    c.Name.Contains(keyword)
            //    ).ToList();

            var search_result = db.Search(keyword).ToList();

            List <Category> categories = new List <Category>();

            foreach (var item in search_result)
            {
                var category = new Category();
                category.Id        = item.Id;
                category.Name      = item.Name;
                category.IsDeleted = item.IsDeleted;
                categories.Add(category);
            }

            return(View("Index", categories));
        }