Admin lösch funktion
This commit is contained in:
@@ -28,8 +28,30 @@
|
||||
<div class="col-md-4 mb-3">
|
||||
<div class="card h-100">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">@(string.IsNullOrEmpty(app.Title) ? "Ingenieur-Antrag" : app.Title)</h5>
|
||||
<h6 class="card-subtitle mb-2 text-muted">von @GetUserName(app.UserId)</h6>
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<h5 class="card-title mb-0">@(string.IsNullOrEmpty(app.Title) ? "Ingenieur-Antrag" : app.Title)</h5>
|
||||
@if (Oqtane.Security.UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
|
||||
{
|
||||
@if (_confirmDeleteId == app.ApplicationId)
|
||||
{
|
||||
<div class="d-flex gap-1">
|
||||
<button class="btn btn-danger btn-sm" @onclick="@(() => DeleteApp(app))" title="Bestätigen">
|
||||
<span class="oi oi-check"></span>
|
||||
</button>
|
||||
<button class="btn btn-secondary btn-sm" @onclick="@(() => _confirmDeleteId = -1)" title="Abbrechen">
|
||||
<span class="oi oi-x"></span>
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-outline-danger btn-sm" @onclick="@(() => _confirmDeleteId = app.ApplicationId)" title="Antrag löschen">
|
||||
<span class="oi oi-trash"></span>
|
||||
</button>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<h6 class="card-subtitle mb-2 text-muted mt-1">von @GetUserName(app.UserId)</h6>
|
||||
@if (!string.IsNullOrEmpty(app.ShortDescription))
|
||||
{
|
||||
<p class="card-text">@app.ShortDescription</p>
|
||||
@@ -112,6 +134,7 @@ else
|
||||
private EngineerApplication _reportApp;
|
||||
private string _reportReason;
|
||||
private Dictionary<int, string> _userNames = new();
|
||||
private int _confirmDeleteId = -1;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -174,6 +197,22 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DeleteApp(EngineerApplication app)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ApplicationService.DeleteApplicationAsync(app.ApplicationId, ModuleState.ModuleId);
|
||||
_applications.Remove(app);
|
||||
_confirmDeleteId = -1;
|
||||
AddModuleMessage("Antrag erfolgreich gelöscht.", MessageType.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddModuleMessage("Fehler beim Löschen: " + ex.Message, MessageType.Error);
|
||||
_confirmDeleteId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetUserName(int userId)
|
||||
{
|
||||
return _userNames.TryGetValue(userId, out var name) ? name : $"Benutzer {userId}";
|
||||
|
||||
Reference in New Issue
Block a user