mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 15:01:56 +00:00
Added Locations update CRUD element, fixed locations index missing cn attribute
This commit is contained in:
31
src/Models/LocationsModels.cs
Normal file
31
src/Models/LocationsModels.cs
Normal 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; }
|
||||
}
|
||||
10
src/Models/LocationsRequestModels.cs
Normal file
10
src/Models/LocationsRequestModels.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Berufsschule_HAM.Models;
|
||||
|
||||
public class LocationsModifyRequestModel
|
||||
{
|
||||
public required string Cn { get; set; }
|
||||
public string? NewCn { get; set; } = null;
|
||||
public LocationsDescription? Description { get; set; } = null;
|
||||
public string? Location { get; set; } = null;
|
||||
public string? Street { get; set; } = null;
|
||||
}
|
||||
Reference in New Issue
Block a user