Merge branch 'react-version' of https://github.com/MarcEricMartel/420-5DW-HY-TP into react-version
This commit is contained in:
		| @@ -3,9 +3,11 @@ using GrossesMitainesAPI.Models; | ||||
| using System.Linq; | ||||
| using GrossesMitainesAPI.Data; | ||||
| using Microsoft.Extensions.Logging; | ||||
| using Microsoft.AspNetCore.Cors; | ||||
|  | ||||
| namespace GrossesMitainesAPI.Controllers; | ||||
|  | ||||
| [EnableCors("_myAllowSpecificOrigins")] | ||||
| [ApiController, Route("api/[controller]")] | ||||
| public class InventoryController : Controller { | ||||
|     private readonly ILogger<InventoryController> _logger; | ||||
| @@ -16,6 +18,7 @@ public class InventoryController : Controller { | ||||
|         _logger = logger; | ||||
|     } | ||||
|  | ||||
|     [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) { | ||||
|         const int AMOUNT = 5; | ||||
| @@ -98,6 +101,7 @@ public class InventoryController : Controller { | ||||
|     } | ||||
|  | ||||
|     // Inventory/Delete => Décrémenter un produit. | ||||
|     [EnableCors("_myAllowSpecificOrigins")] | ||||
|     [HttpDelete(Name = "Inventory")] | ||||
|     public void Delete(int? id) { | ||||
|         if (!id.HasValue) { | ||||
|   | ||||
| @@ -5,6 +5,7 @@ using GrossesMitainesAPI.Data; | ||||
| using Microsoft.Extensions.Logging; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.AspNetCore.Cors; | ||||
|  | ||||
| namespace GrossesMitainesAPI.Controllers; | ||||
|  | ||||
| @@ -18,6 +19,7 @@ public class ProductController : Controller { | ||||
|         _context = context; | ||||
|     } | ||||
|  | ||||
|     [EnableCors("_myAllowSpecificOrigins")] | ||||
|     [HttpGet(Name = "Product"), AllowAnonymous] | ||||
|     public Product Get(int id) { | ||||
|         Product prod; | ||||
| @@ -30,6 +32,7 @@ public class ProductController : Controller { | ||||
|         return prod; | ||||
|     } | ||||
|  | ||||
|     [EnableCors("_myAllowSpecificOrigins")] | ||||
|     [HttpPost(Name = "Product")] | ||||
|     public void Post(string title, string category, string description, decimal? price, decimal? promoprice, uint? quantity, string? status, string imagename) { | ||||
|         Product prod = new() { | ||||
| @@ -75,6 +78,7 @@ public class ProductController : Controller { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     [EnableCors("_myAllowSpecificOrigins")] | ||||
|     [HttpPut(Name = "Product")] | ||||
|     public void Put(int id, string title, string category, string description, decimal? price, decimal? promoprice, uint? quantity, string? status, string imagename) { | ||||
|         Product prod = _context.Products.Where(x => x.Id == id).FirstOrDefault(); | ||||
| @@ -132,6 +136,7 @@ public class ProductController : Controller { | ||||
|             } | ||||
|     } | ||||
|  | ||||
|     [EnableCors("_myAllowSpecificOrigins")] | ||||
|     [HttpPatch(Name = "Product")] | ||||
|     public void Patch(int id, string title, string category, string description, decimal? price, decimal? promoprice, uint? quantity, string? status, string imagename) { | ||||
|         try { | ||||
| @@ -187,6 +192,7 @@ public class ProductController : Controller { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     [EnableCors("_myAllowSpecificOrigins")] | ||||
|     [HttpDelete(Name = "Product")] | ||||
|     public void DeleteProduct(int id) { | ||||
|         try { | ||||
|   | ||||
| @@ -4,9 +4,11 @@ using System.Linq; | ||||
| using GrossesMitainesAPI.Data; | ||||
| using Microsoft.Extensions.Logging; | ||||
| using Microsoft.AspNetCore.Authorization; | ||||
| using Microsoft.AspNetCore.Cors; | ||||
|  | ||||
| namespace GrossesMitainesAPI.Controllers; | ||||
|  | ||||
| [EnableCors("_myAllowSpecificOrigins")] | ||||
| [ApiController, Route("api/[controller]")] | ||||
| public class SearchController : Controller { | ||||
|     private readonly ILogger<SearchController> _logger; | ||||
| @@ -17,6 +19,7 @@ public class SearchController : Controller { | ||||
|         _context = context; | ||||
|     } | ||||
|  | ||||
|     [EnableCors("_myAllowSpecificOrigins")] | ||||
|     [HttpPost(Name = "Search")] | ||||
|     public IEnumerable<Product> Post(string query, bool? preview) { | ||||
|         const int PREVIEW = 3; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user