react-version #1
@ -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<InventoryController> 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<Product> Get(int? lastId, string? order, string? filterPrice, string? filterState, bool? all) {
|
||||
const int AMOUNT = 5;
|
||||
bool islock = false;
|
||||
IQueryable<Product> 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) {
|
||||
|
Loading…
Reference in New Issue
Block a user