Update SearchController.cs
This commit is contained in:
		| @@ -44,9 +44,9 @@ public class SearchController : Controller { | |||||||
|                     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.ToArray()) { |                     foreach (Product prod in _context.Products.ToArray()) { | ||||||
|                         string sTitle = prod.Title.Replace(",", " ").ToLower(), |                         string sTitle = prod.Title.Replace(",", " ").ToLower() + " ", | ||||||
|                                sCat = prod.Category.ToLower(), |                                sCat = prod.Category.ToLower() + " ", | ||||||
|                                sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower(); |                                sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower() + " "; | ||||||
|                         if (sTitle.StartsWith(query)) |                         if (sTitle.StartsWith(query)) | ||||||
|                             products.Add(prod); |                             products.Add(prod); | ||||||
|                         else if (sTitle.Contains(" " + query + " ")) |                         else if (sTitle.Contains(" " + query + " ")) | ||||||
| @@ -90,9 +90,9 @@ public class SearchController : Controller { | |||||||
|                     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 _searchCache) { |                     foreach (Product prod in _searchCache) { | ||||||
|                         string sTitle = prod.Title.Replace(",", " ").ToLower(), |                         string sTitle = prod.Title.Replace(",", " ").ToLower() + " ", | ||||||
|                                sCat = prod.Category.ToLower(), |                                sCat = prod.Category.ToLower() + " ", | ||||||
|                                sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower(); |                                sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower() + " "; | ||||||
|                         if (sTitle.StartsWith(query)) |                         if (sTitle.StartsWith(query)) | ||||||
|                             products.Add(prod); |                             products.Add(prod); | ||||||
|                         else if (sTitle.Contains(" " + query + " ")) |                         else if (sTitle.Contains(" " + query + " ")) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user