mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Added asset inventory information and action in AssetsController
This commit is contained in:
@@ -181,16 +181,20 @@ public class AssetsController : Controller
|
||||
{
|
||||
await _ldap.UpdateAsset(cn, "serialNumber", requestModel.SerialNumber);
|
||||
}
|
||||
AssetModel asset = await _ldap.ListDeviceAsync(requestModel.Cn);
|
||||
asset.Description ??= new();
|
||||
if (requestModel.Description is not null)
|
||||
{
|
||||
AssetModel? asset = null;
|
||||
asset = await _ldap.GetAssetByCnAsync(cn);
|
||||
if (asset.Description is null)
|
||||
{
|
||||
asset.Description = new();
|
||||
}
|
||||
AssetInventory? tempInventory = asset.Description.Inventory;
|
||||
AttributesHelper.UpdateNonNullProperties(requestModel.Description, asset.Description);
|
||||
await _ldap.UpdateAsset(cn, "description", JsonSerializer.Serialize(requestModel.Description));
|
||||
asset.Description.Inventory = tempInventory;
|
||||
await _ldap.UpdateAsset(cn, "description", JsonSerializer.Serialize(asset.Description));
|
||||
}
|
||||
if (requestModel.UpdateInventory)
|
||||
{
|
||||
string? userName = User.Identity?.Name ?? "Unknown";
|
||||
asset.Description.Inventory = new() { Date = DateTime.Now.ToString("yyyy-MM-dd"), PersonUid = userName };
|
||||
await _ldap.UpdateAsset(cn, "description", JsonSerializer.Serialize(asset.Description));
|
||||
}
|
||||
|
||||
result = new AssetsUpdateResponseModel(successful: true);
|
||||
|
||||
Reference in New Issue
Block a user