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 10:08:26 -04:00
2 changed files with 4 additions and 4 deletions

View File

@@ -22,13 +22,14 @@ public class SearchController : Controller {
[EnableCors("_myAllowSpecificOrigins")]
[HttpPost(Name = "Search")]
public IEnumerable<Product> Post(string query, bool? preview) {
const int PREVIEW = 3;
HashSet<Product> products = new();
query = query.Trim();
try { // Pour faire une liste priorisée.
if (preview.HasValue && preview == true)
products = _context.Products.Where(x => x.Title.Contains(query)).Take(3).ToHashSet();
products = _context.Products.Where(x => x.Title.Contains(query)).Take(PREVIEW).ToHashSet();
else {
products.Concat(_context.Products.Where(x => x.Title.Contains(query)).ToHashSet());
products.Concat(_context.Products.Where(x => x.Category.Contains(query)).ToHashSet());
@@ -39,7 +40,5 @@ public class SearchController : Controller {
}
return products;
}
}