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

This commit is contained in:
David Belisle 2022-10-18 13:04:08 -04:00
commit bd55393123
4 changed files with 11 additions and 9 deletions

View File

@ -62,10 +62,10 @@ public class InventoryController : Controller {
switch (order) { switch (order) {
case "Price": case "Price":
ret = ret.OrderBy(x => x.Status == Product.States.Promotion? x.PromoPrice: x.Price); ret = ret.OrderBy(x => x.Status == Product.States.Promotion || x.Status == Product.States.Clearance? x.PromoPrice: x.Price);
break; break;
case "PriceDesc": case "PriceDesc":
ret = ret.OrderByDescending(x => x.Status == Product.States.Promotion ? x.PromoPrice : x.Price); ret = ret.OrderByDescending(x => x.Status == Product.States.Promotion || x.Status == Product.States.Clearance ? x.PromoPrice : x.Price);
break; break;
case "Title": case "Title":
ret = ret.OrderBy(x => x.Title); ret = ret.OrderBy(x => x.Title);

View File

@ -54,8 +54,8 @@ public class ProductController : ControllerBase {
} }
[EnableCors("_myAllowSpecificOrigins")] [EnableCors("_myAllowSpecificOrigins")]
[HttpPut(Name = "Product")] [HttpPatch(Name = "Product")]
public ActionResult<Product> Put(Product prod) { public ActionResult<Product> Patch(Product prod) {
try { try {
_context.Products.Update(prod); _context.Products.Update(prod);
_context.SaveChanges(); _context.SaveChanges();

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);

View File

@ -33,8 +33,10 @@ const Inventaire = () => {
const newMorceau = await response.json(); const newMorceau = await response.json();
console.log(newMorceau); console.log(newMorceau);
if (response.ok) if (response.ok) {
setMorceaux([...morceaux, { ...newMorceau }]); setMorceaux([...morceaux, { ...newMorceau }]);
console.log("Ajout de l'item avec succès: \r\n" + newMorceau);
}
else else
console.log("Erreur de creation " + morceau); console.log("Erreur de creation " + morceau);
}; };