Added Locations update CRUD element, fixed locations index missing cn attribute

This commit is contained in:
2025-10-03 22:13:39 +02:00
parent 7eff665f81
commit 4d0d3ac473
5 changed files with 107 additions and 5 deletions

View File

@@ -0,0 +1,31 @@
namespace Berufsschule_HAM.Models;
using System.Text.Json;
using Berufsschule_HAM.Exceptions;
public class LocationModel
{
public required string Cn { get; set; }
public LocationsDescription? Description { get; set; }
public string? Location { get; set; }
public string? Street { get; set; }
public LocationModel(Dictionary<string, string> ldapData)
{
Cn = ldapData.GetValueOrDefault("cn") ?? throw new LocationModelConfigurationException();
Location = ldapData.GetValueOrDefault("l");
Street = ldapData.GetValueOrDefault("street");
string? descriptionValue = ldapData.GetValueOrDefault("description");
if (descriptionValue is null)
{
Description = new();
}
else
{
Description = JsonSerializer.Deserialize<LocationsDescription>(descriptionValue);
}
}
}
public class LocationsDescription
{
public string? RoomNumber { get; set; }
public string? Seat { get; set; }
}