Added Users table

This commit is contained in:
2025-10-09 10:36:12 +02:00
parent 2676ab7f0f
commit 41cc78d321
6 changed files with 96 additions and 42 deletions

View File

@@ -1,3 +1,5 @@
using System.Text.Json;
namespace Berufsschule_HAM.Models;
public class UserModel
@@ -5,7 +7,7 @@ public class UserModel
public required string Uid { get; set; }
public string? Cn { get; set; }
public string? Sn { get; set; }
public string? Description { get; set; }
public UserDescription? Description { get; set; }
public string? JpegPhoto { get; set; }
public string? Title { get; set; }
public string? UserPassword { get; set; }
@@ -14,13 +16,28 @@ public class UserModel
Uid = ldapData.GetValueOrDefault("uid") ?? throw new ArgumentException("UID is required");
Cn = ldapData.GetValueOrDefault("cn");
Sn = ldapData.GetValueOrDefault("sn");
Description = ldapData.GetValueOrDefault("description");
string? description = ldapData.GetValueOrDefault("description");
Description = description != null ? JsonSerializer.Deserialize<UserDescription>(description) : null;
JpegPhoto = ldapData.GetValueOrDefault("jpegPhoto");
Title = ldapData.GetValueOrDefault("title");
UserPassword = ldapData.GetValueOrDefault("userPassword");
}
}
public class UserDescription
{
public required string BirthDate { get; set; }
public required UserAddress Address { get; set; }
public required string Workplace { get; set; }
}
public class UserAddress
{
public string? City { get; set; }
public string? Street { get; set; }
public string? StreetNr { get; set; }
}
public class UserAuthenticationResult
{
public required bool Success;
@@ -33,4 +50,14 @@ public enum UserNotAuthenticatedReason
InvalidCredentials,
UserNotAuthorized,
UserLockedOut
}
public class UserTableViewModel
{
public required string JpegPhoto { get; set; }
public required string Uid { get; set; }
public required string Title { get; set; }
public required string Name { get; set; }
public required string Surname { get; set; }
public required string Workplace { get; set; }
}

View File

@@ -21,4 +21,11 @@ public class UsersModifyRequestModel
public string? Description { get; set; } = null;
public string? JpegPhoto { get; set; } = null;
public string? UserPassword { get; set; } = null;
}
public class UsersDeleteRequestModel(bool successful, string exception = "None")
{
public bool Success { get; set; } = successful;
public string? Exception { get; set; } = exception;
}

View File

@@ -0,0 +1,6 @@
namespace Berufsschule_HAM.Models;
public class UsersIndexViewModel
{
public required IEnumerable<UserTableViewModel> UserTableViewModels { get; set; }
}