Gossage dans API
This commit is contained in:
@@ -5,6 +5,7 @@ using GrossesMitainesAPI.Data;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using GrossesMitainesAPI.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace GrossesMitainesAPI.Controllers;
|
||||
|
||||
@@ -22,7 +23,7 @@ public class InventoryController : Controller {
|
||||
_cache = cache;
|
||||
}
|
||||
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpGet(Name = "Inventory")] // Pour faire des calls async par paquet de AMOUNT (5) (pour du loading en scrollant)
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpGet(Name = "Inventory"), AllowAnonymous] // 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) {
|
||||
bool islock = false;
|
||||
IQueryable<Product> ret;
|
||||
@@ -127,7 +128,7 @@ public class InventoryController : Controller {
|
||||
}
|
||||
}
|
||||
// Inventory/Delete => Décrémenter un produit. Va aller chercher directement dans la BD.
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpDelete(Name = "Inventory")]
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpDelete(Name = "Inventory"), AllowAnonymous]
|
||||
public ActionResult<int> Delete(int? id) {
|
||||
int rid = 0;
|
||||
if (!id.HasValue) {
|
||||
@@ -139,6 +140,8 @@ public class InventoryController : Controller {
|
||||
rid = prod.Id;
|
||||
if (prod.Quantity > 0) {
|
||||
prod.Quantity = prod.Quantity - 1;
|
||||
prod.Sales = prod.Sales + 1;
|
||||
prod.LastSale = DateTime.Now;
|
||||
if (prod.Quantity == 0)
|
||||
prod.Status = prod.Status == Product.States.Clearance?
|
||||
Product.States.Discontinued:
|
||||
|
Reference in New Issue
Block a user