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:
2026-02-09 12:52:29 +01:00
parent 47eade57a3
commit 2c81583831

View File

@@ -8,8 +8,8 @@ namespace EnvelopeGenerator.Application.Common.Commands;
/// </summary>
/// <typeparam name="TCommand"></typeparam>
/// <typeparam name="TEntity"></typeparam>
public class CreateCommandHandler<TCommand, TEntity> : IRequestHandler<TCommand>
where TCommand : class, IRequest
public class CreateCommandHandler<TCommand, TEntity> : IRequestHandler<TCommand, TEntity>
where TCommand : class, IRequest<TEntity>
where TEntity : class
{
/// <summary>
@@ -32,5 +32,5 @@ public class CreateCommandHandler<TCommand, TEntity> : IRequestHandler<TCommand>
/// <param name="request"></param>
/// <param name="cancel"></param>
/// <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);
}