mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Implemented automated asset counter into asset creation and asset update, Fixed uid visible in owner attribute in Assets frontend
This commit is contained in:
@@ -28,6 +28,10 @@ public class AssetsController : Controller
|
||||
{
|
||||
var assetList = await _ldap.ListDeviceAsync(Cn);
|
||||
result = new AssetsGetResponseModel(successful: true, assetModel: assetList);
|
||||
if (result.AssetsModel is not null)
|
||||
{
|
||||
result.AssetsModel.Owner = result.AssetsModel?.Owner?.Replace("uid=", "");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -45,6 +49,11 @@ public class AssetsController : Controller
|
||||
{
|
||||
var assetList = await _ldap.ListDeviceAsync();
|
||||
result = new AssetsGetAllResponseModel(successful: true, assetsModel: assetList);
|
||||
result.AssetsModel = result.AssetsModel?.Select(asset =>
|
||||
{
|
||||
asset.Owner = asset.Owner?.Replace("uid=", "");
|
||||
return asset;
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -71,13 +80,10 @@ public class AssetsController : Controller
|
||||
{
|
||||
LdapAttributeSet attributeSet =
|
||||
[
|
||||
new LdapAttribute("objectClass", new[] {"top", "device", "extensibleObject"}),
|
||||
new LdapAttribute("objectClass", ["top", "device", "extensibleObject"]),
|
||||
];
|
||||
|
||||
if (assetModel.Cn != null)
|
||||
{
|
||||
attributeSet.Add(new LdapAttribute("cn", assetModel.Cn));
|
||||
}
|
||||
attributeSet.Add(new LdapAttribute("cn", await _ldap.GetAssetCounterAndIncrementAsync()));
|
||||
if (assetModel.SerialNumber != null)
|
||||
{
|
||||
attributeSet.Add(new LdapAttribute("serialNumber", assetModel.SerialNumber));
|
||||
@@ -168,7 +174,7 @@ public class AssetsController : Controller
|
||||
}
|
||||
if (requestModel.Owner is not null)
|
||||
{
|
||||
await _ldap.UpdateAsset(cn, "owner", requestModel.Owner);
|
||||
await _ldap.UpdateAsset(cn, "owner", $"uid={requestModel.Owner}");
|
||||
}
|
||||
if (requestModel.SerialNumber is not null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user