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>
|
||||
/// <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);
|
||||
}
|
||||
Reference in New Issue
Block a user