mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Use new response model for create call
This commit is contained in:
@@ -37,12 +37,16 @@ public class AssetsController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("Create")]
|
[HttpPost("Create")]
|
||||||
public async Task<bool> Create(AssetsCreateRequestModel assetModel)
|
public async Task<AssetsResponseModel> Create(AssetsCreateRequestModel assetModel)
|
||||||
{
|
{
|
||||||
|
AssetsResponseModel result;
|
||||||
if (assetModel is null)
|
if (assetModel is null)
|
||||||
{
|
{
|
||||||
_logger.LogError("Unable to create an asset because the AssetModel is null.");
|
result = new AssetsResponseModel(
|
||||||
return false;
|
successful: false,
|
||||||
|
exception: "Unable to create an asset because the AssetsCreateRequestModel is null.");
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -108,14 +112,14 @@ public class AssetsController : Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
await _ldap.CreateAsset(attributeSet);
|
await _ldap.CreateAsset(attributeSet);
|
||||||
|
result = new AssetsResponseModel(successful: true);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
_logger.LogError($"Unable to create an asset because of the exception: {e.Message}", e);
|
result = new AssetsResponseModel(successful: false, exception: e.Message);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("Delete")]
|
[HttpDelete("Delete")]
|
||||||
|
|||||||
Reference in New Issue
Block a user