aktualisieren seite eingebaut
This commit is contained in:
@@ -55,6 +55,43 @@ public class FahrzeugController : Controller
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Aktualisieren(int id)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
string connectionString = this.GetConnectionString();
|
||||
var repository = new FahrzeugRepository(connectionString);
|
||||
var fahrzeug = repository.GetFahrzeugByID(id);
|
||||
var model = new FahrzeugAktualisierenModel();
|
||||
model.Id = fahrzeug.Id;
|
||||
model.Type = fahrzeug.Typ;
|
||||
model.Name = fahrzeug.Name;
|
||||
return View(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Aktualisieren(FahrzeugAktualisierenModel model)
|
||||
{
|
||||
if (ModelState.IsValid && !string.IsNullOrEmpty(model.Name) && !string.IsNullOrEmpty(model.Type))
|
||||
{
|
||||
string connectionString = this.GetConnectionString();
|
||||
var repository = new FahrzeugRepository(connectionString);
|
||||
int id = (int)model.Id;
|
||||
repository.AktualisiereFahrzeug(id, model.Name, model.Type);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
else
|
||||
{
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Loesche(int id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user