Added groups view model, implemented basic groups table view

This commit is contained in:
2025-10-11 13:29:59 +02:00
parent d9127736d9
commit fd5dcb5618
5 changed files with 65 additions and 20 deletions

View File

@@ -7,12 +7,14 @@ namespace Berufsschule_HAM.Models;
public class GroupModel
{
public required string Cn { get; set; }
public string DisplayName { get; set; }
public string? GidNumber { get; set; }
public List<GroupPermission> Permissions { get; set; }
public GroupModel(Dictionary<string, string> ldapData)
{
Cn = ldapData.GetValueOrDefault("cn") ?? throw new GroupModelConfigurationException();
GidNumber = ldapData.GetValueOrDefault("gidNumber");
DisplayName = ldapData.GetValueOrDefault("displayName") ?? Cn;
string? descriptionValue = ldapData.GetValueOrDefault("description");
if (descriptionValue is null)
{

View File

@@ -0,0 +1,38 @@
namespace Berufsschule_HAM.Models;
public class GroupsIndexViewModel
{
public List<GroupsTableViewModel> GroupsTableViewModels { get; set; } = [];
public GroupsIndexViewModel(IEnumerable<GroupModel> groupModels)
{
foreach (GroupModel model in groupModels)
{
GroupsTableViewModels.Add(new()
{
Cn = model.Cn,
Group = model.DisplayName,
CanInventorize = model.Permissions.Any(x => x == GroupPermission.CanInventorize),
CanManageAssets = model.Permissions.Any(x => x == GroupPermission.CanManageAssets),
CanManageGroups = model.Permissions.Any(x => x == GroupPermission.CanManageGroups),
CanManageLocations = model.Permissions.Any(x => x == GroupPermission.CanManageLocations),
CanManageUsers = model.Permissions.Any(x => x == GroupPermission.CanManageUsers)
});
}
}
}
public class GroupsTableViewModel
{
public required string Cn { get; set; }
public required string Group { get; set; }
public required bool CanInventorize { get; set; }
public required bool CanManageUsers { get; set; }
public required bool CanManageLocations { get; set; }
public required bool CanManageAssets { get; set; }
public required bool CanManageGroups { get; set; }
}