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),
                CanManageSettings = model.Permissions.Any(x => x == GroupPermission.CanManageSettings)
            });
        }
    }

    
    

}

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; }
    public required bool CanManageSettings { get; set; }
}