feature: suche
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user