View:
-
- Title: "text" name="SearchString" />
- Description: "text" name="SearchString" />
- "submit" value="Filter" />
- public class Product
- {
- public int Id { get; set; }
- public string Title { get; set; }
- public int Price { get; set; }
- [Display(Name = "Product description")]
- public string ProductDescription { get; set; }
- public int Stock { get; set; }
- }
Controller:
- public async Task
Index(string searchString, string description) - {
- var store = from m in _context.Products
- select m;
- if (!String.IsNullOrEmpty(searchString))
- {
- store = store.Where(s => s.Title.Contains(searchString));
- }
- if (!String.IsNullOrEmpty(description))
- {
- store = store.Where(s => s.ProductDescription.Contains(description));
- }
- return View(await store.ToListAsync());
- }
Kiran MohantyPosted Mar 1, 2021, 1:38 PM
osyris zosarPosted Feb 28, 2021, 6:31 PM
price, brand,name,delivery,Instock,popular,newProducts,outofstock. etc
that would be a very long code because you will have to create
a "else if statement" for every possible combination.
I dont think that would be a good solution
Sachin SinghPosted Feb 28, 2021, 6:26 PM
osyris zosarPosted Feb 28, 2021, 6:24 PM
its basicly a simple search on a E-commerce webpage
so it could be that the user only uses one field or all of them
Sachin SinghPosted Feb 28, 2021, 8:06 AM
Jignesh KumarPosted Feb 28, 2021, 7:23 AM