Renvoit du rôle au frontend avec Get Login (UPDATE-DATABASE)

This commit is contained in:
MarcEricMartel
2022-11-01 10:33:08 -07:00
parent 5112762ac9
commit cd37fd2c15
16 changed files with 761 additions and 125 deletions

View File

@@ -44,7 +44,7 @@ public class ProductController : ControllerBase {
#region API Methods
[EnableCors("_myAllowSpecificOrigins"), HttpGet(Name = "Product"), AllowAnonymous]
public ActionResult<ProductViewModel> Get(int id) {
Product prod;
ProductModel prod;
try {
prod = _context.Products.Where(x => x.Id == id).First();
}
@@ -57,7 +57,7 @@ public class ProductController : ControllerBase {
}
[EnableCors("_myAllowSpecificOrigins"), HttpPost(Name = "Product")]
public async Task<ActionResult<Product>> Post(Product prod) {
public async Task<ActionResult<ProductModel>> Post(ProductModel prod) {
if (prod.Price <= prod.PromoPrice)
prod.PromoPrice = prod.Price - 0.01M;
try {
@@ -76,7 +76,7 @@ public class ProductController : ControllerBase {
}
[EnableCors("_myAllowSpecificOrigins"), HttpPatch(Name = "Product")]
public ActionResult<Product> Patch(Product prod) {
public ActionResult<ProductModel> Patch(ProductModel prod) {
try {
_context.Products.Update(prod);
_context.SaveChanges();