Update InventoryController.cs

This commit is contained in:
MarcEricMartel 2022-10-18 07:36:13 -07:00
parent 4e61ad4aa3
commit 49381ca6f6

View File

@ -78,14 +78,23 @@ public class InventoryController : Controller {
break; break;
default: break; default: break;
} }
if (order is not null && order.Contains("Desc")) {
if (!lastId.HasValue)
lastId = _context.Products.Max(x => x.Id) + 1;
} else
if (!lastId.HasValue)
lastId = _context.Products.Min(x => x.Id) - 1;
return ret.Where(x => x.Id > lastId).Take(AMOUNT).ToList(); List<Product> lst = ret.ToList();
if (lastId.HasValue)
foreach (Product prod in new List<Product>(lst)) {
lst.Remove(prod);
if (prod.Id == lastId)
break;
}
//if (order is not null && order.Contains("Desc")) {
// if (!lastId.HasValue)
// lastId = _context.Products.Max(x => x.Id) + 1;
//} else
// if (!lastId.HasValue)
// lastId = _context.Products.Min(x => x.Id) - 1;
return lst.Take(AMOUNT);
} }
// Inventory/Delete => Décrémenter un produit. // Inventory/Delete => Décrémenter un produit.