SearchCache va call Search s'il plante

This commit is contained in:
MarcEricMartel
2022-10-25 09:02:27 -07:00
parent 1180e404aa
commit 6371d350fa
3 changed files with 12 additions and 39 deletions

View File

@@ -16,8 +16,7 @@ namespace GrossesMitainesAPI.Controllers;
/// qui sera effectuée dans les 10 secondes après
/// l'éxécution d'une modification de la BD.
/// </summary>
[EnableCors("_myAllowSpecificOrigins")]
[ApiController, Route("api/[controller]")]
[EnableCors("_myAllowSpecificOrigins"), ApiController, Route("api/[controller]")]
public class ProductController : ControllerBase {
private readonly ILogger<ProductController> _logger;
private readonly InventoryContext _context;
@@ -29,8 +28,7 @@ public class ProductController : ControllerBase {
_cache = cache;
}
[EnableCors("_myAllowSpecificOrigins")]
[HttpGet(Name = "Product"), AllowAnonymous]
[EnableCors("_myAllowSpecificOrigins"), HttpGet(Name = "Product"), AllowAnonymous]
public ActionResult<Product> Get(int id) {
Product prod;
try {
@@ -43,8 +41,7 @@ public class ProductController : ControllerBase {
return prod;
}
[EnableCors("_myAllowSpecificOrigins")]
[HttpPost(Name = "Product")]
[EnableCors("_myAllowSpecificOrigins"), HttpPost(Name = "Product")]
public ActionResult<Product> Post(Product prod) {
if (prod.Price <= prod.PromoPrice)
prod.PromoPrice = prod.Price - 0.01M;
@@ -60,8 +57,7 @@ public class ProductController : ControllerBase {
return prod;
}
[EnableCors("_myAllowSpecificOrigins")]
[HttpPatch(Name = "Product")]
[EnableCors("_myAllowSpecificOrigins"), HttpPatch(Name = "Product")]
public ActionResult<Product> Patch(Product prod) {
try {
_context.Products.Update(prod);
@@ -75,8 +71,7 @@ public class ProductController : ControllerBase {
return prod;
}
[EnableCors("_myAllowSpecificOrigins")]
[HttpDelete(Name = "Product")]
[EnableCors("_myAllowSpecificOrigins"), HttpDelete(Name = "Product")]
public ActionResult<int> DeleteProduct(int id) {
try {
_context.Products.Remove(_context.Products.Where(x => x.Id == id).First());