Merge branch 'react-version' of https://github.com/MarcEricMartel/420-5DW-HY-TP into react-version
This commit is contained in:
commit
dc71afe986
@ -22,13 +22,14 @@ public class SearchController : Controller {
|
|||||||
[EnableCors("_myAllowSpecificOrigins")]
|
[EnableCors("_myAllowSpecificOrigins")]
|
||||||
[HttpPost(Name = "Search")]
|
[HttpPost(Name = "Search")]
|
||||||
public IEnumerable<Product> Post(string query, bool? preview) {
|
public IEnumerable<Product> Post(string query, bool? preview) {
|
||||||
|
const int PREVIEW = 3;
|
||||||
HashSet<Product> products = new();
|
HashSet<Product> products = new();
|
||||||
|
|
||||||
query = query.Trim();
|
query = query.Trim();
|
||||||
|
|
||||||
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(3).ToHashSet();
|
products = _context.Products.Where(x => x.Title.Contains(query)).Take(PREVIEW).ToHashSet();
|
||||||
else {
|
else {
|
||||||
products.Concat(_context.Products.Where(x => x.Title.Contains(query)).ToHashSet());
|
products.Concat(_context.Products.Where(x => x.Title.Contains(query)).ToHashSet());
|
||||||
products.Concat(_context.Products.Where(x => x.Category.Contains(query)).ToHashSet());
|
products.Concat(_context.Products.Where(x => x.Category.Contains(query)).ToHashSet());
|
||||||
@ -39,7 +40,5 @@ public class SearchController : Controller {
|
|||||||
}
|
}
|
||||||
return products;
|
return products;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject",
|
||||||
|
"startsrv": "cd ../GrossesMitainesAPI/ & dotnet run"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": [
|
||||||
|
Loading…
Reference in New Issue
Block a user