Implemented frontend Assets update button

This commit is contained in:
2025-10-10 19:52:28 +02:00
parent fd20b2ae2d
commit dd865b99be
5 changed files with 312 additions and 11 deletions

View File

@@ -20,18 +20,35 @@ public class AssetsController : Controller
_logger = logger;
}
[HttpGet("GetAll")]
public async Task<AssetsIndexResponseModel> GetAllAssetModelAsync()
[HttpGet("Get")]
public async Task<AssetsGetResponseModel> GetAllAssetModelAsync(string Cn)
{
AssetsIndexResponseModel result;
AssetsGetResponseModel result;
try
{
var assetList = await _ldap.ListDeviceAsync();
result = new AssetsIndexResponseModel(successful: true, assetsModel: assetList);
var assetList = await _ldap.ListDeviceAsync(Cn);
result = new AssetsGetResponseModel(successful: true, assetModel: assetList);
}
catch (Exception e)
{
result = new AssetsIndexResponseModel(successful: false, exception: e.Message);
result = new AssetsGetResponseModel(successful: false, exception: e.Message);
}
return result;
}
[HttpGet("GetAll")]
public async Task<AssetsGetAllResponseModel> GetAllAssetModelAsync()
{
AssetsGetAllResponseModel result;
try
{
var assetList = await _ldap.ListDeviceAsync();
result = new AssetsGetAllResponseModel(successful: true, assetsModel: assetList);
}
catch (Exception e)
{
result = new AssetsGetAllResponseModel(successful: false, exception: e.Message);
}
return result;
@@ -121,7 +138,7 @@ public class AssetsController : Controller
}
[HttpPatch("Update")]
public async Task<AssetsUpdateResponseModel> Update(AssetsModifyRequestModel requestModel)
public async Task<AssetsUpdateResponseModel> Update([FromBody]AssetsModifyRequestModel requestModel)
{
AssetsUpdateResponseModel result;
if (requestModel is null)
@@ -161,6 +178,10 @@ public class AssetsController : Controller
{
AssetModel? asset = null;
asset = await _ldap.GetAssetByCnAsync(cn);
if (asset.Description is null)
{
asset.Description = new();
}
AttributesHelper.UpdateNonNullProperties(requestModel.Description, asset.Description);
await _ldap.UpdateAsset(cn, "description", JsonSerializer.Serialize(requestModel.Description));
}