argh.
This commit is contained in:
@@ -13,6 +13,7 @@ using GrossesMitainesAPI.Services;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -44,12 +45,12 @@ public class ProductController : ControllerBase {
|
||||
#endregion
|
||||
|
||||
#region API Methods
|
||||
[EnableCors("_myAllowSpecificOrigins"), Route("Quantity"), HttpGet(Name = "Product"), AllowAnonymous]
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpGet("Quantity"), AllowAnonymous]
|
||||
public ActionResult<uint> ProdCount(int id) {
|
||||
return _context.Products.FirstOrDefault(x => x.Id == id).Quantity;
|
||||
}
|
||||
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpGet(Name = "Product"), AllowAnonymous]
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpGet(), AllowAnonymous]
|
||||
public ActionResult<ProductViewModel> Get(int id) {
|
||||
ProductModel prod;
|
||||
try {
|
||||
@@ -63,7 +64,7 @@ public class ProductController : ControllerBase {
|
||||
return new ProductViewModel(prod);
|
||||
}
|
||||
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpPost(Name = "Product")]
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpPost()]
|
||||
public async Task<ActionResult<ProductModel>> Post([FromForm] ProductModel prod) {
|
||||
if (prod.Price <= prod.PromoPrice)
|
||||
prod.PromoPrice = prod.Price - 0.01M;
|
||||
@@ -82,7 +83,7 @@ public class ProductController : ControllerBase {
|
||||
return prod;
|
||||
}
|
||||
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpPatch(Name = "Product")]
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpPatch()]
|
||||
public async Task<ActionResult<ProductModel>> Patch([FromForm] ProductModel prod) {
|
||||
string? oldImage = "";
|
||||
try {
|
||||
@@ -106,7 +107,7 @@ public class ProductController : ControllerBase {
|
||||
return prod;
|
||||
}
|
||||
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpDelete(Name = "Product")]
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpDelete()]
|
||||
public ActionResult<int> Delete(int id) {
|
||||
try {
|
||||
var prod = _context.Products.Where(x => x.Id == id).First();
|
||||
|
Reference in New Issue
Block a user