Files
Berufsschule_HAM/src/Views/Home/Index.cshtml
2025-10-18 23:33:13 +02:00

56 lines
1.8 KiB
Plaintext

@using Berufsschule_HAM.Services
@using Microsoft.AspNetCore.Mvc.Localization
@using Berufsschule_HAM.Models
@using System.Security.Claims
@model HomeIndexViewModel
@inject IViewLocalizer T
@inject LdapService _ldap
@{
ViewData["Title"] = T["Home Page"];
bool hasName = User.Identity?.Name is not null;
string? username;
string name = "";
UserModel? user;
if (hasName && User.Identity is not null && User.Identity.Name is not null)
{
username = User.Identity.Name;
user = await _ldap.GetUserByUidAsync(username);
name = user.Cn ?? "";
}
}
<div class="container py-4">
<div class="row text-center">
@if (name.Length > 0)
{
<h3>@T["Hi, {0}!", name]</h3>
} else
{
<h3>@T["Hi!"]</h3>
}
<p>@T["Navigate from here or the navigation bar"]</p>
<div class="mb-4 d-flex flex-wrap gap-2 justify-content-center">
@if (User.HasClaim(ClaimTypes.Role, "CanInventorize"))
{
<a href="/Home/Inventory" class="btn btn-primary">@T["Inventory"]</a>
}
@if (User.HasClaim(ClaimTypes.Role, "CanManageAssets"))
{
<a href="/Home/Assets" class="btn btn-primary">@T["Manage Assets"]</a>
}
@if (User.HasClaim(ClaimTypes.Role, "CanManageLocations"))
{
<a href="/Home/Locations" class="btn btn-primary">@T["Manage Locations"]</a>
}
@if (User.HasClaim(ClaimTypes.Role, "CanManageUsers"))
{
<a href="/Home/Users" class="btn btn-primary">@T["Manage Users"]</a>
}
@if (User.HasClaim(ClaimTypes.Role, "CanManageGroups"))
{
<a href="/Home/Groups" class="btn btn-primary">@T["Manage Groups"]</a>
}
</div>
</div>
</div>