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);
|
||||
|
||||
@@ -50,6 +50,8 @@ public class AssetDescription
|
||||
public Dictionary<string, string>? Attributes { get; set; }
|
||||
[JsonPropertyName("Purchase")]
|
||||
public AssetPurchase? Purchase { get; set; }
|
||||
[JsonPropertyName("Inventory")]
|
||||
public AssetInventory? Inventory { get; set; }
|
||||
}
|
||||
|
||||
public class AssetPurchase
|
||||
@@ -64,6 +66,15 @@ public class AssetPurchase
|
||||
public string? PurchasedBy { get; set; }
|
||||
}
|
||||
|
||||
public class AssetInventory
|
||||
{
|
||||
[JsonPropertyName("Date")]
|
||||
public required string Date { get; set; }
|
||||
[JsonPropertyName("PersonUid")]
|
||||
public required string PersonUid { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class AssetsTableViewModel
|
||||
{
|
||||
public string? UserUID { get; set; }
|
||||
|
||||
@@ -28,4 +28,6 @@ public class AssetsModifyRequestModel
|
||||
public string? Owner { get; set; } = null;
|
||||
[JsonPropertyName("SerialNumber")]
|
||||
public string? SerialNumber { get; set; } = null;
|
||||
[JsonPropertyName("UpdateInventory")]
|
||||
public bool UpdateInventory { get; set; } = false;
|
||||
}
|
||||
Reference in New Issue
Block a user