api: implement entity converters
This commit is contained in:
20
Pilz.Net/Api/Entities/IEntityConverter.cs
Normal file
20
Pilz.Net/Api/Entities/IEntityConverter.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using Pilz.Data;
|
||||||
|
|
||||||
|
namespace Pilz.Net.Api.Entities;
|
||||||
|
|
||||||
|
public interface IEntityConverter<TEntity, TUpdateMsg>
|
||||||
|
where TEntity : class, IDataObject
|
||||||
|
where TUpdateMsg : ApiMessage
|
||||||
|
{
|
||||||
|
IDataObject ConvertToClient(TEntity entityServer, IDataManager manager);
|
||||||
|
ApiResult? UpdateEntity(EntityUpdate<TEntity, TUpdateMsg> entityUpdate, IDataManager manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IEntityConverter<TEntity, TParent, TUpdateMsg>
|
||||||
|
where TEntity : class, IDataObject
|
||||||
|
where TParent : class, IDataObject
|
||||||
|
where TUpdateMsg : ApiMessage
|
||||||
|
{
|
||||||
|
IDataObject ConvertToClient(TEntity entityServer, IDataManager manager);
|
||||||
|
ApiResult? UpdateEntity(EntityUpdate<TEntity, TParent, TUpdateMsg> entityUpdate, IDataManager manager);
|
||||||
|
}
|
||||||
18
Pilz.Net/Api/Entities/IEntityConverterProvider.cs
Normal file
18
Pilz.Net/Api/Entities/IEntityConverterProvider.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using Pilz.Data;
|
||||||
|
|
||||||
|
namespace Pilz.Net.Api.Entities;
|
||||||
|
|
||||||
|
public interface IEntityConverterProvider<TEntity, TUpdateMsg>
|
||||||
|
where TEntity : class, IDataObject
|
||||||
|
where TUpdateMsg : ApiMessage
|
||||||
|
{
|
||||||
|
IEntityConverter<TEntity, TUpdateMsg>? GetEntityConverter() => this as IEntityConverter<TEntity, TUpdateMsg>;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IEntityConverterProvider<TEntity, TParent, TUpdateMsg>
|
||||||
|
where TEntity : class, IDataObject
|
||||||
|
where TParent : class, IDataObject
|
||||||
|
where TUpdateMsg : ApiMessage
|
||||||
|
{
|
||||||
|
IEntityConverter<TEntity, TParent, TUpdateMsg>? GetEntityConverter() => this as IEntityConverter<TEntity, TParent, TUpdateMsg>;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user