mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Implemented Groups edit buttons
This commit is contained in:
@@ -6,15 +6,18 @@ namespace Berufsschule_HAM.Models;
|
||||
|
||||
public class GroupModel
|
||||
{
|
||||
[JsonPropertyName("Cn")]
|
||||
public required string Cn { get; set; }
|
||||
[JsonPropertyName("DisplayName")]
|
||||
public string DisplayName { get; set; }
|
||||
[JsonPropertyName("GidNumber")]
|
||||
public string? GidNumber { get; set; }
|
||||
[JsonPropertyName("Permissions")]
|
||||
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)
|
||||
{
|
||||
@@ -22,13 +25,18 @@ public class GroupModel
|
||||
}
|
||||
else
|
||||
{
|
||||
Permissions = JsonSerializer.Deserialize<GroupPermissions>(descriptionValue)?.Permissions ?? [];
|
||||
GroupDescription? description = JsonSerializer.Deserialize<GroupDescription>(descriptionValue);
|
||||
DisplayName = description?.DisplayName ?? Cn;
|
||||
Permissions = description?.Permissions ?? [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GroupPermissions
|
||||
public class GroupDescription
|
||||
{
|
||||
[JsonPropertyName("DisplayName")]
|
||||
public required string DisplayName { get; set; }
|
||||
[JsonPropertyName("Permissions")]
|
||||
public required List<GroupPermission> Permissions { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,12 @@ public class GroupsCreateRequestModel
|
||||
|
||||
public class GroupsModifyRequestModel
|
||||
{
|
||||
[JsonPropertyName("Cn")]
|
||||
public required string Cn { get; set; }
|
||||
[JsonPropertyName("NewCn")]
|
||||
public string? NewCn { get; set; } = null;
|
||||
[JsonPropertyName("GidNumber")]
|
||||
public string? GidNumber { get; set; } = null;
|
||||
public GroupPermissions? Permissions { get; set; } = null;
|
||||
[JsonPropertyName("Description")]
|
||||
public GroupDescription? Description { get; set; } = null;
|
||||
}
|
||||
@@ -1,11 +1,27 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Berufsschule_HAM.Models;
|
||||
|
||||
public class GroupsGetResponseModel(bool successful, IEnumerable<GroupModel>? groupModels, string exception = "None")
|
||||
{
|
||||
public bool Success { get; set; } = successful;
|
||||
[JsonPropertyName("GroupModels")]
|
||||
public IEnumerable<GroupModel> GroupModels { get; set; } = groupModels ?? [];
|
||||
public string? Exception { get; set; } = exception;
|
||||
}
|
||||
|
||||
public class GroupsCreateResponseModel(bool successful, string exception = "None")
|
||||
{
|
||||
public bool Success { get; set; } = successful;
|
||||
public string? Exception { get; set; } = exception;
|
||||
}
|
||||
|
||||
public class GroupsUpdateResponseModel(bool successful, string exception = "None")
|
||||
{
|
||||
public bool Success { get; set; } = successful;
|
||||
public string? Exception { get; set; } = exception;
|
||||
}
|
||||
|
||||
public class GroupsDeleteResponseModel(bool successful, string exception = "None")
|
||||
{
|
||||
public bool Success { get; set; } = successful;
|
||||
|
||||
Reference in New Issue
Block a user