diff options
Diffstat (limited to 'Controllers/FigureController.cs')
-rw-r--r-- | Controllers/FigureController.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Controllers/FigureController.cs b/Controllers/FigureController.cs index 5785f86..03616bc 100644 --- a/Controllers/FigureController.cs +++ b/Controllers/FigureController.cs @@ -54,5 +54,26 @@ namespace MyDarling.Controllers } return View(figure); } + + [HttpPost] + public async Task<ActionResult> Delete(int id) + { + var figureToDelete = await context.Figures.FindAsync(id); + if (figureToDelete == null) + { + return NotFound(); + } + + try + { + context.Figures.Remove(figureToDelete); + await context.SaveChangesAsync(); + return RedirectToAction(nameof(Index), "Bundle"); + } + catch (DbUpdateException) + { + return RedirectToAction(nameof(Delete), new { id = id, saveChangesError = true }); + } + } } }
\ No newline at end of file |