Added Assets update CRUD element

This commit is contained in:
2025-10-03 23:07:55 +02:00
parent a803218982
commit b262a73d9d
6 changed files with 139 additions and 16 deletions

46
src/Models/AssetsModel.cs Normal file
View File

@@ -0,0 +1,46 @@
namespace Berufsschule_HAM.Models;
using System.Text.Json;
using Berufsschule_HAM.Exceptions;
public class AssetModel
{
public required string Cn { get; set; }
public string? SerialNumber { get; set; }
public AssetDescription? Description { get; set; }
public string? Location { get; set; }
public string? Owner { get; set; }
public string? Name { get; set; }
public AssetModel(Dictionary<string, string> ldapData)
{
Cn = ldapData.GetValueOrDefault("cn") ?? throw new AssetModelConfigurationException();
SerialNumber = ldapData.GetValueOrDefault("serialNumber");
Location = ldapData.GetValueOrDefault("l");
Owner = ldapData.GetValueOrDefault("owner");
Name = ldapData.GetValueOrDefault("name");
string? descriptionValue = ldapData.GetValueOrDefault("description");
if (descriptionValue is null)
{
Description = new();
}
else
{
Description = JsonSerializer.Deserialize<AssetDescription>(descriptionValue) ?? new();
}
}
}
public class AssetDescription
{
public string? Type { get; set; }
public AssetPurchase? Purchase { get; set; }
}
public class AssetPurchase
{
public string? PurchaseDate { get; set; }
public string? PurchaseValue { get; set; }
public string? PurchasedAt { get; set; }
public string? PurchasedBy { get; set; }
}