feature: suche

This commit is contained in:
2025-04-30 01:10:55 +02:00
parent 1273aced0c
commit 20303466b6
3 changed files with 49 additions and 4 deletions

View File

@@ -7,14 +7,23 @@ namespace FahrzeugeMVC.Controllers;
public class FahrzeugController : Controller
{
public IActionResult Index()
public IActionResult Index(string searchTerm)
{
string connectionString = this.GetConnectionString();
var respsitory = new FahrzeugRepository(connectionString);
List<FahrzeugDTO>? fahrzeugs = respsitory.HoleAlleFahrzeuge();
var repository = new FahrzeugRepository(connectionString);
List<FahrzeugDTO> fahrzeugs;
if (!string.IsNullOrEmpty(searchTerm))
{
fahrzeugs = repository.SucheFahrzeuge(searchTerm);
}
else
{
fahrzeugs = repository.HoleAlleFahrzeuge();
}
var model = new FahrzeugListeModel(fahrzeugs);
return View(model);
}

View File

@@ -2,6 +2,13 @@
<p>Diese Fahrzeuge befinden sich derzeit in der Datenbank:</p>
<form asp-action="Index" asp-controller="Fahrzeug" method="get" class="mb-3">
<div class="input-group">
<input type="text" name="searchTerm" class="form-control" placeholder="Fahrzeug suchen..." />
<button class="btn btn-primary" type="submit">Suchen</button>
</div>
</form>
<table class="table table-hover mb-0">
<thead>
<tr>