Update SearchController.cs

This commit is contained in:
MarcEricMartel 2022-10-26 13:27:24 -07:00
parent 750653ff72
commit e40807b6a2

View File

@ -44,9 +44,9 @@ public class SearchController : Controller {
List<Product> title = new(), desc = new(), cat = new();
query = query.ToLower();
foreach (Product prod in _context.Products.ToArray()) {
string sTitle = prod.Title.Replace(",", " ").ToLower(),
sCat = prod.Category.ToLower(),
sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower();
string sTitle = prod.Title.Replace(",", " ").ToLower() + " ",
sCat = prod.Category.ToLower() + " ",
sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower() + " ";
if (sTitle.StartsWith(query))
products.Add(prod);
else if (sTitle.Contains(" " + query + " "))
@ -90,9 +90,9 @@ public class SearchController : Controller {
List<Product> title = new(), desc = new(), cat = new();
query = query.ToLower();
foreach (Product prod in _searchCache) {
string sTitle = prod.Title.Replace(",", " ").ToLower(),
sCat = prod.Category.ToLower(),
sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower();
string sTitle = prod.Title.Replace(",", " ").ToLower() + " ",
sCat = prod.Category.ToLower() + " ",
sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower() + " ";
if (sTitle.StartsWith(query))
products.Add(prod);
else if (sTitle.Contains(" " + query + " "))