public async Task <IActionResult> OnPostDelete() { if (!await _invManager.ProductExists(ID.GetValueOrDefault())) { return(RedirectToPage("/Admin/Products/Index")); } await _invManager.DeleteProduct(ID.GetValueOrDefault()); return(RedirectToPage("/Admin/Products/Index")); }
[HttpGet("product/delete/{productId}")] //check if want to make it delete type public ActionResult <ResponseModel> DeleteProduct(int productId) //add dto here to protect the id //but no need in a way,since we may have to share id anyway { var success = _inventoryManager.DeleteProduct(productId); if (success) { return(Ok()); } return(BadRequest()); }
public async Task <IActionResult> OnPostDelete() { await _product.DeleteProduct(ID.GetValueOrDefault()); return(RedirectToPage("ProductManagement")); }
public async Task <IActionResult> OnGet() { await _product.DeleteProduct(ID); return(RedirectToPage("ProductManagement")); }