mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2026-03-22 02:13:13 +00:00
Added Assets update CRUD element
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
namespace Berufsschule_HAM.Models;
|
||||
public class Asset
|
||||
{
|
||||
public required string Dn { get; set; } // Full LDAP DN (readonly in many cases)
|
||||
public required string CommonName { get; set; } // cn (display name)
|
||||
public required string SerialNumber { get; set; } // serialNumber
|
||||
public required string Description { get; set; } // description (notes)
|
||||
public required string Location { get; set; } // l (location)
|
||||
public required string Owner { get; set; } // owner (uid of owner)
|
||||
}
|
||||
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; }
|
||||
}
|
||||
12
src/Models/AssetsRequestModels.cs
Normal file
12
src/Models/AssetsRequestModels.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Berufsschule_HAM.Models;
|
||||
|
||||
public class AssetsModifyRequestModel
|
||||
{
|
||||
public required string Cn { get; set; }
|
||||
public string? NewCn { get; set; } = null;
|
||||
public AssetDescription? Description { get; set; } = null;
|
||||
public string? Location { get; set; } = null;
|
||||
public string? Name { get; set; } = null;
|
||||
public string? Owner { get; set; } = null;
|
||||
public string? SerialNumber { get; set; } = null;
|
||||
}
|
||||
Reference in New Issue
Block a user