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