diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs index a9f7694..bab580b 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/InventoryController.cs @@ -16,6 +16,8 @@ public class InventoryController : Controller { private readonly DatabaseCacheService _cache; private static object _lock = new object(); + private const int AMOUNT_SCROLL = 5; + public InventoryController(ILogger logger, InventoryContext context, DatabaseCacheService cache) { _context = context; _logger = logger; @@ -25,7 +27,6 @@ public class InventoryController : Controller { [EnableCors("_myAllowSpecificOrigins")] [HttpGet(Name = "Inventory")] // Pour faire des calls async par paquet de AMOUNT (5) (pour du loading en scrollant) public IEnumerable Get(int? lastId, string? order, string? filterPrice, string? filterState, bool? all) { - const int AMOUNT = 5; bool islock = false; IQueryable ret; @@ -106,7 +107,7 @@ public class InventoryController : Controller { } else prods = ret.ToList(); foreach (Product prod in prods) { - if (yup && add < AMOUNT) { + if (yup && add < AMOUNT_SCROLL) { lst.Add(prod); add++; } @@ -121,9 +122,9 @@ public class InventoryController : Controller { else lst = ret.ToList(); } else if (islock) lock (_lock) { - lst = ret.Take(AMOUNT).ToList(); + lst = ret.Take(AMOUNT_SCROLL).ToList(); } - else lst = ret.Take(AMOUNT).ToList(); + else lst = ret.Take(AMOUNT_SCROLL).ToList(); return lst; } catch (Exception e) {