Cleanup on aisle Search
This commit is contained in:
parent
ffe5919354
commit
144ff9478f
@ -35,15 +35,12 @@ public class SearchController : Controller {
|
||||
|
||||
try { // Pour faire une liste priorisée.
|
||||
if (preview.HasValue && preview == true)
|
||||
//products = _context.Products.Where(x => x.Title.Contains(query)).Take(PREVIEW).ToList();
|
||||
products = _searchCache.Where(x => x.Title.Contains(query)).Take(PREVIEW).ToList();
|
||||
|
||||
else {
|
||||
if (deep.HasValue && deep == true) {
|
||||
List<Product> title = new(), desc = new(), cat = new();
|
||||
query = query.ToLower();
|
||||
|
||||
// foreach (Product prod in _context.Products.ToList()) {
|
||||
foreach (Product prod in _searchCache) {
|
||||
string sTitle = prod.Title.Replace(".", " ").Replace(",", " ").ToLower(),
|
||||
sCat = prod.Category.Replace(".", " ").Replace(",", " ").ToLower(),
|
||||
@ -61,16 +58,11 @@ public class SearchController : Controller {
|
||||
products.AddRange(title);
|
||||
products.AddRange(desc);
|
||||
products.AddRange(cat);
|
||||
|
||||
} else {
|
||||
// products = _context.Products.Where(x => x.Title.Contains(query)).ToList();
|
||||
products = _searchCache.Where(x => x.Title.Contains(query)).ToList();
|
||||
|
||||
// foreach (Product prod in _context.Products.Where(x => x.Description.Contains(query)).ToList())
|
||||
foreach (Product prod in _searchCache.Where(x => x.Description.Contains(query)).ToList())
|
||||
if (!products.Contains(prod))
|
||||
products.Add(prod);
|
||||
// foreach (Product prod in _context.Products.Where(x => x.Category.Contains(query)).ToList())
|
||||
foreach (Product prod in _searchCache.Where(x => x.Category.Contains(query)).ToList())
|
||||
if (!products.Contains(prod))
|
||||
products.Add(prod);
|
||||
|
Loading…
Reference in New Issue
Block a user