react-version #1
@ -62,10 +62,10 @@ public class InventoryController : Controller {
|
||||
|
||||
switch (order) {
|
||||
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;
|
||||
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;
|
||||
case "Title":
|
||||
ret = ret.OrderBy(x => x.Title);
|
||||
|
@ -54,8 +54,8 @@ public class ProductController : ControllerBase {
|
||||
}
|
||||
|
||||
[EnableCors("_myAllowSpecificOrigins")]
|
||||
[HttpPut(Name = "Product")]
|
||||
public ActionResult<Product> Put(Product prod) {
|
||||
[HttpPatch(Name = "Product")]
|
||||
public ActionResult<Product> Patch(Product prod) {
|
||||
try {
|
||||
_context.Products.Update(prod);
|
||||
_context.SaveChanges();
|
||||
|
@ -42,16 +42,16 @@ public class SearchController : Controller {
|
||||
query = query.ToLower();
|
||||
|
||||
foreach (Product prod in _searchCache) {
|
||||
string sTitle = prod.Title.Replace(".", " ").Replace(",", " ").ToLower(),
|
||||
sCat = prod.Category.Replace(".", " ").Replace(",", " ").ToLower(),
|
||||
string sTitle = prod.Title.Replace(",", " ").ToLower(),
|
||||
sCat = prod.Category.ToLower(),
|
||||
sDesc = prod.Description.Replace(".", " ").Replace(",", " ").ToLower();
|
||||
if (sTitle.StartsWith(query))
|
||||
products.Add(prod);
|
||||
else if (sTitle.Contains(" " + query + " "))
|
||||
title.Add(prod);
|
||||
else if (sDesc.Contains(" " + query + " "))
|
||||
else if (sDesc.StartsWith(query) || sDesc.Contains(" " + query + " "))
|
||||
desc.Add(prod);
|
||||
else if (sCat.Contains(" " + query + " "))
|
||||
else if (sCat.Contains(query))
|
||||
cat.Add(prod);
|
||||
}
|
||||
products.AddRange(title);
|
||||
|
@ -33,8 +33,10 @@ const Inventaire = () => {
|
||||
const newMorceau = await response.json();
|
||||
console.log(newMorceau);
|
||||
|
||||
if (response.ok)
|
||||
if (response.ok) {
|
||||
setMorceaux([...morceaux, { ...newMorceau }]);
|
||||
console.log("Ajout de l'item avec succès: \r\n" + newMorceau);
|
||||
}
|
||||
else
|
||||
console.log("Erreur de creation " + morceau);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user