feature: löschen von objekten
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using FahrzeugDatenBank;
|
||||
using FahrzeugeMVC.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Reflection;
|
||||
|
||||
namespace FahrzeugeMVC.Controllers;
|
||||
|
||||
@@ -44,4 +45,17 @@ public class FahrzeugController : Controller
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Loesche(int id)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
string connectionString = this.GetConnectionString();
|
||||
var repository = new FahrzeugRepository(connectionString);
|
||||
repository.LoescheFahrzeug(id);
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
<td>@fahrzeug.Id</td>
|
||||
<td>@fahrzeug.Name</td>
|
||||
<td>@fahrzeug.GetType()</td>
|
||||
<td>
|
||||
<a asp-action=Loesche asp-controller="Fahrzeug" asp-route-id=@fahrzeug.Id>Löschen</a>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user