use ChildEntityUpdate also on PUT
This commit is contained in:
@@ -54,6 +54,18 @@ public abstract class BaseChildItemHandler<TEntity, TParent, TUpdateMsg>(IApiSer
|
|||||||
return ToClient(entity).ToItemResult(HttpStatusCode.Created);
|
return ToClient(entity).ToItemResult(HttpStatusCode.Created);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override ApiResult Put(int id, TUpdateMsg msg, ApiRequestInfo req)
|
||||||
|
{
|
||||||
|
if (server.Manager.Get<TParent>().FirstOrDefault(n => GetChilds(n).Any(n => n.Id == id)) is not TParent parentEntity)
|
||||||
|
return ApiResult.NotFound();
|
||||||
|
if (!server.Manager.Find(id, out TEntity? entity))
|
||||||
|
return ApiResult.NotFound();
|
||||||
|
if (UpdateEntity(new ChildEntityUpdate(entity, parentEntity, msg, req)) is ApiResult result)
|
||||||
|
return result;
|
||||||
|
server.Manager.Save(entity, true);
|
||||||
|
return ToClient(entity).ToItemResult();
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual TEntity CreateNewEntity(TUpdateMsg msg, TParent parent)
|
protected virtual TEntity CreateNewEntity(TUpdateMsg msg, TParent parent)
|
||||||
{
|
{
|
||||||
return CreateNewEntity(msg);
|
return CreateNewEntity(msg);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>2.5.2</Version>
|
<Version>2.5.3</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user