public ViewResult SearchLocalSellers(String query) // the value gotten from the url { LocalProductContext context = HttpContext.RequestServices.GetService(typeof(MechanicChecker.Models.LocalProductContext)) as LocalProductContext; IEnumerable <LocalProduct> listOfQueriedProducts; var allProducts = context.GetAllProducts(); if (query != null) { listOfQueriedProducts = allProducts.Where( product => product.Title.Contains(query) || product.Description.Contains(query) ); } else { listOfQueriedProducts = allProducts; } return(View("SearchResultsList", listOfQueriedProducts)); }
public IActionResult Index() { LocalProductContext context = HttpContext.RequestServices.GetService(typeof(MechanicChecker.Models.LocalProductContext)) as LocalProductContext; return(View(context.GetAllProducts())); }