Fixed created assets not showing on list until site refresh

This commit is contained in:
2025-10-12 20:03:30 +02:00
parent 090db4a1ab
commit 04c39feb7a
3 changed files with 39 additions and 4 deletions

View File

@@ -66,6 +66,7 @@ public class AssetsController : Controller
[HttpPost("Create")]
public async Task<AssetsCreateResponseModel> Create([FromBody]AssetsCreateRequestModel assetModel)
{
string? assetId;
AssetsCreateResponseModel result;
if (assetModel is null)
{
@@ -82,8 +83,8 @@ public class AssetsController : Controller
[
new LdapAttribute("objectClass", ["top", "device", "extensibleObject"]),
];
attributeSet.Add(new LdapAttribute("cn", await _ldap.GetAssetCounterAndIncrementAsync()));
assetId = await _ldap.GetAssetCounterAndIncrementAsync();
attributeSet.Add(new LdapAttribute("cn", assetId));
if (assetModel.SerialNumber != null)
{
attributeSet.Add(new LdapAttribute("serialNumber", assetModel.SerialNumber));
@@ -107,7 +108,7 @@ public class AssetsController : Controller
}
await _ldap.CreateAsset(attributeSet);
result = new AssetsCreateResponseModel(successful: true);
result = new AssetsCreateResponseModel(successful: true, assetId);
}
catch (Exception e)
{