mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Implemented frontend Assets update button
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user