This commit is contained in:
2025-08-22 10:19:33 +02:00
parent abe438ba0d
commit 2f15ef4173
3 changed files with 15 additions and 5 deletions

View File

@@ -13,12 +13,14 @@ public class ServerController : Controller
private readonly ILogger<ServerController> _logger;
public ServerController(AppDbContext context, ILogger<ServerController> logger)
{
_context = context;
_logger = logger;
}
[HttpGet("Overview")]
public async Task<IActionResult> Overview()
{
@@ -30,15 +32,17 @@ public class ServerController : Controller
return View(vm);
}
[HttpGet("AddServer")]
public IActionResult AddServer()
{
return View();
}
[HttpPost("AddServer")]
// POST: Server/AddServer
[HttpPost("CreateServer")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AddServer(AddServerViewModel vm)
public async Task<IActionResult> CreateServer(AddServerViewModel vm)
{
if (!ModelState.IsValid)
return View(vm);
@@ -59,6 +63,7 @@ public class ServerController : Controller
return RedirectToAction("Overview");
}
// POST: Server/Delete/5
[HttpPost("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Delete(int id)
@@ -78,8 +83,9 @@ public class ServerController : Controller
return RedirectToAction(nameof(Overview));
}
// GET: Server/Edit/5
[HttpGet("EditServer/[id]")]
[HttpGet("EditServer/{id}")]
public async Task<IActionResult> EditServer(int id)
{
var server = await _context.Servers.FindAsync(id);
@@ -95,6 +101,7 @@ public class ServerController : Controller
return View(vm);
}
// POST: Server/Edit/5
[HttpPost("EditServer/{id}")]
[ValidateAntiForgeryToken]
@@ -129,6 +136,7 @@ public class ServerController : Controller
}
}
// GET: Server/Details/5
[HttpGet("Details/{id}")]
public async Task<IActionResult> Details(int id)
@@ -157,6 +165,7 @@ public class ServerController : Controller
return View(vm);
}
[HttpGet("ServerCardPartial")]
public async Task<IActionResult> ServerCardsPartial()
{
@@ -171,6 +180,7 @@ public class ServerController : Controller
return PartialView("_ServerCard", servers);
}
[HttpGet("ServerDetailPartial")]
public IActionResult ServerDetailPartial()
{

View File

@@ -9,7 +9,7 @@
<i class="bi bi-plus-circle me-2"></i>Neuen Server hinzufügen
</h1>
<form asp-action="AddServer" asp-controller="Server" method="post">
<form asp-action="CreateServer" asp-controller="Server" method="post">
@Html.AntiForgeryToken()
<div class="mb-3">
<label asp-for="Name" class="form-label"><i class="bi bi-terminal me-1"></i>Servername</label>

View File

@@ -7,7 +7,7 @@
<h1 class="h2 fw-bold mb-0">
<i class="bi bi-hdd-network me-2 text-primary"></i>Serverübersicht
</h1>
<a asp-controller="Server" asp-action="AddServer" class="btn btn-primary d-flex align-items-center gap-1">
<a asp-controller="Server" asp-action="AddServer" method="get" class="btn btn-primary d-flex align-items-center gap-1">
<i class="bi bi-plus-circle"></i> Server hinzufügen
</a>
</div>