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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return CreateNewEntity(msg);
|
||||
|
||||
Reference in New Issue
Block a user