Update CreateCommandHandler to return created entity
Changed CreateCommandHandler to implement IRequestHandler<TCommand, TEntity> and updated method signatures to return the created entity. Adjusted generic constraints to require TCommand to implement IRequest<TEntity>.
This commit is contained in:
@@ -8,8 +8,8 @@ namespace EnvelopeGenerator.Application.Common.Commands;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TCommand"></typeparam>
|
/// <typeparam name="TCommand"></typeparam>
|
||||||
/// <typeparam name="TEntity"></typeparam>
|
/// <typeparam name="TEntity"></typeparam>
|
||||||
public class CreateCommandHandler<TCommand, TEntity> : IRequestHandler<TCommand>
|
public class CreateCommandHandler<TCommand, TEntity> : IRequestHandler<TCommand, TEntity>
|
||||||
where TCommand : class, IRequest
|
where TCommand : class, IRequest<TEntity>
|
||||||
where TEntity : class
|
where TEntity : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -32,5 +32,5 @@ public class CreateCommandHandler<TCommand, TEntity> : IRequestHandler<TCommand>
|
|||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <param name="cancel"></param>
|
/// <param name="cancel"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public Task Handle(TCommand request, CancellationToken cancel) => Repository.CreateAsync(request, cancel);
|
public Task<TEntity> Handle(TCommand request, CancellationToken cancel) => Repository.CreateAsync(request, cancel);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user