From 84e6bb9bc393a1b665ac0590ee2d17e0dc2ce0b3 Mon Sep 17 00:00:00 2001 From: MarcEricMartel <74071476+MarcEricMartel@users.noreply.github.com> Date: Tue, 18 Oct 2022 08:01:16 -0700 Subject: [PATCH] Update ProductController.cs --- .../Controllers/ProductController.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/GrossesMitaines/GrossesMitainesAPI/Controllers/ProductController.cs b/GrossesMitaines/GrossesMitainesAPI/Controllers/ProductController.cs index fc4acc2..f19c82c 100644 --- a/GrossesMitaines/GrossesMitainesAPI/Controllers/ProductController.cs +++ b/GrossesMitaines/GrossesMitainesAPI/Controllers/ProductController.cs @@ -186,4 +186,14 @@ public class ProductController : Controller { _logger.LogError(8, e.Message); } } + + [HttpDelete(Name = "Product")] + public void DeleteProduct(int id) { + try { + _context.Products.Remove(_context.Products.Where(x => x.Id == id).First()); + _context.SaveChanges(); + } catch (Exception e) { + _logger.LogError(8, e.Message); + } + } } \ No newline at end of file