pass throw update message for CreateNewEntity
This commit is contained in:
@@ -40,7 +40,7 @@ public abstract class BaseChildItemHandler<TEntity, TParent, TUpdateMsg>(IApiSer
|
|||||||
{
|
{
|
||||||
if (!server.Manager.Find(parent, out TParent? parentEntity))
|
if (!server.Manager.Find(parent, out TParent? parentEntity))
|
||||||
return ApiResult.NotFound();
|
return ApiResult.NotFound();
|
||||||
var entity = CreateNewEntity();
|
var entity = CreateNewEntity(msg);
|
||||||
if (UpdateEntity(entity, msg) is ApiResult result)
|
if (UpdateEntity(entity, msg) is ApiResult result)
|
||||||
return result;
|
return result;
|
||||||
GetChilds(parentEntity).Add(entity);
|
GetChilds(parentEntity).Add(entity);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public abstract class BaseHandler<TEntity, TUpdateMsg>(IApiServer server)
|
|||||||
return ApiResult.Ok();
|
return ApiResult.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual TEntity CreateNewEntity()
|
protected virtual TEntity CreateNewEntity(TUpdateMsg msg)
|
||||||
{
|
{
|
||||||
return Activator.CreateInstance<TEntity>();
|
return Activator.CreateInstance<TEntity>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public abstract class BaseItemHandler<TEntity, TUpdateMsg>(IApiServer server)
|
|||||||
|
|
||||||
public virtual ApiResult Post(TUpdateMsg msg)
|
public virtual ApiResult Post(TUpdateMsg msg)
|
||||||
{
|
{
|
||||||
var entity = CreateNewEntity();
|
var entity = CreateNewEntity(msg);
|
||||||
if (UpdateEntity(entity, msg) is ApiResult result)
|
if (UpdateEntity(entity, msg) is ApiResult result)
|
||||||
return result;
|
return result;
|
||||||
server.Manager.Save(entity, true);
|
server.Manager.Save(entity, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user