Username wird jetzt auch angezeigt beim antrag
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
@inherits ModuleBase
|
@inherits ModuleBase
|
||||||
@inject IEngineerApplicationService ApplicationService
|
@inject IEngineerApplicationService ApplicationService
|
||||||
@inject NavigationManager NavManager
|
@inject NavigationManager NavManager
|
||||||
|
@inject Oqtane.Services.IUserService UserService
|
||||||
|
|
||||||
@if (Oqtane.Security.UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin) || Oqtane.Security.UserSecurity.IsAuthorized(PageState.User, "Premium Member"))
|
@if (Oqtane.Security.UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin) || Oqtane.Security.UserSecurity.IsAuthorized(PageState.User, "Premium Member"))
|
||||||
{
|
{
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
<div class="card h-100">
|
<div class="card h-100">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">@(string.IsNullOrEmpty(app.Title) ? "Ingenieur-Antrag" : app.Title)</h5>
|
<h5 class="card-title">@(string.IsNullOrEmpty(app.Title) ? "Ingenieur-Antrag" : app.Title)</h5>
|
||||||
<h6 class="card-subtitle mb-2 text-muted">Benutzer ID: @app.UserId</h6>
|
<h6 class="card-subtitle mb-2 text-muted">von @GetUserName(app.UserId)</h6>
|
||||||
@if (!string.IsNullOrEmpty(app.ShortDescription))
|
@if (!string.IsNullOrEmpty(app.ShortDescription))
|
||||||
{
|
{
|
||||||
<p class="card-text">@app.ShortDescription</p>
|
<p class="card-text">@app.ShortDescription</p>
|
||||||
@@ -90,7 +91,7 @@ else
|
|||||||
<button type="button" class="btn-close" @onclick="@(() => _reportApp = null)"></button>
|
<button type="button" class="btn-close" @onclick="@(() => _reportApp = null)"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<p>Bitte geben Sie einen Grund an, warum Sie diesen Antrag melden (Benutzer ID: @_reportApp.UserId, Datei: @_reportApp.FileId).</p>
|
<p>Bitte geben Sie einen Grund an, warum Sie diesen Antrag melden (von @GetUserName(_reportApp.UserId)).</p>
|
||||||
<textarea class="form-control" rows="3" @bind="_reportReason" placeholder="Grund..."></textarea>
|
<textarea class="form-control" rows="3" @bind="_reportReason" placeholder="Grund..."></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
@@ -110,6 +111,7 @@ else
|
|||||||
private EngineerApplication _selectedApp;
|
private EngineerApplication _selectedApp;
|
||||||
private EngineerApplication _reportApp;
|
private EngineerApplication _reportApp;
|
||||||
private string _reportReason;
|
private string _reportReason;
|
||||||
|
private Dictionary<int, string> _userNames = new();
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
@@ -123,6 +125,20 @@ else
|
|||||||
if (approved != null) _applications.AddRange(approved);
|
if (approved != null) _applications.AddRange(approved);
|
||||||
|
|
||||||
_applications = _applications.GroupBy(a => a.ApplicationId).Select(g => g.First()).ToList();
|
_applications = _applications.GroupBy(a => a.ApplicationId).Select(g => g.First()).ToList();
|
||||||
|
|
||||||
|
// Benutzernamen laden
|
||||||
|
foreach (var userId in _applications.Select(a => a.UserId).Distinct())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var user = await UserService.GetUserAsync(userId, ModuleState.SiteId);
|
||||||
|
_userNames[userId] = user?.DisplayName ?? $"Benutzer {userId}";
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_userNames[userId] = $"Benutzer {userId}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -158,4 +174,9 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetUserName(int userId)
|
||||||
|
{
|
||||||
|
return _userNames.TryGetValue(userId, out var name) ? name : $"Benutzer {userId}";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user