Have a different reponse model for get all

This commit is contained in:
anomny
2025-10-06 21:25:10 +02:00
parent c25e196814
commit 1d26781e8e
2 changed files with 4 additions and 17 deletions

View File

@@ -20,20 +20,11 @@ public class AssetsController : Controller
} }
[HttpGet("GetAll")] [HttpGet("GetAll")]
public async Task<AssetsResponseModel> GetAllAssetModelAsync() public async Task<IEnumerable<AssetModel>> GetAllAssetModelAsync()
{ {
AssetsResponseModel result; var assetsList = await _ldap.ListDeviceAsync();
try
{
var assetList = await _ldap.ListDeviceAsync();
result = new AssetsResponseModel(successful: true, assetsModel: assetList);
}
catch (Exception e)
{
result = new AssetsResponseModel(successful: false, exception: e.Message);
}
return result; return assetsList;
} }
[HttpPost("Create")] [HttpPost("Create")]

View File

@@ -1,11 +1,7 @@
using Berufsschule_HAM.Models; public class AssetsResponseModel(bool successful, string exception = "None")
public class AssetsResponseModel(bool successful, IEnumerable<AssetModel>? assetsModel = null, string exception = "None")
{ {
public bool Success { get; set; } = successful; public bool Success { get; set; } = successful;
public IEnumerable<AssetModel>? AssetsModel { get; set; } = assetsModel;
public string? Exception { get; set; } = exception; public string? Exception { get; set; } = exception;
} }