react-version #1

Merged
memartel_loc merged 290 commits from react-version into main 2023-11-04 09:48:15 -04:00
Showing only changes of commit db4fc250b9 - Show all commits

View File

@ -18,8 +18,6 @@ public class InventoryController : Controller {
[HttpGet(Name = "Inventory")] // Pour faire des calls async par paquet de 5 (pour du loading en scrollant)
public IEnumerable<Product> Get(int? lastId, string order, string filter) {
if (!lastId.HasValue)
lastId = 1;
var ret = _context.Products.AsQueryable();
switch (filter) {
@ -75,9 +73,18 @@ public class InventoryController : Controller {
.Where(x => x.Id < lastId && x.Id > lastId - 5);
break;
default:
ret = ret.Where(x => x.Id > lastId && x.Id < lastId + 5);
break;
}
if (order.Contains("Desc")) {
if (!lastId.HasValue)
lastId = _context.Products.Max(x => x.Id);
ret = ret.Where(x => x.Id < lastId && x.Id > lastId - 5)
} else {
if (!lastId.HasValue)
lastId = 1;
ret = ret.Where(x => x.Id > lastId && x.Id < lastId + 5);
}
return ret.ToList();
}