Merge branch 'react-version' of https://github.com/MarcEricMartel/420-5DW-HY-TP into react-version

This commit is contained in:
Victor Turgeon 2022-10-18 12:20:06 -04:00
commit 0a6f9b4884

View File

@ -42,16 +42,16 @@ public class SearchController : Controller {
query = query.ToLower(); query = query.ToLower();
foreach (Product prod in _searchCache) { foreach (Product prod in _searchCache) {
string sTitle = prod.Title.Replace(".", " ").Replace(",", " ").ToLower(), string sTitle = prod.Title.Replace(",", " ").ToLower(),
sCat = prod.Category.Replace(".", " ").Replace(",", " ").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 + " "))
title.Add(prod); title.Add(prod);
else if (sDesc.Contains(" " + query + " ")) else if (sDesc.StartsWith(query) || sDesc.Contains(" " + query + " "))
desc.Add(prod); desc.Add(prod);
else if (sCat.Contains(" " + query + " ")) else if (sCat.Contains(query))
cat.Add(prod); cat.Add(prod);
} }
products.AddRange(title); products.AddRange(title);