mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added Assets update CRUD element
This commit is contained in:
46
src/Models/AssetsModel.cs
Normal file
46
src/Models/AssetsModel.cs
Normal 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; }
|
||||
}
|
||||
Reference in New Issue
Block a user