Adds Generic CommandHandlerDecorator

This commit is contained in:
Janus C. H. Knudsen 2025-03-12 00:13:53 +01:00
parent 49f9b99ee1
commit 64e696dc5a
21 changed files with 131 additions and 110 deletions

View file

@ -1,13 +1,14 @@
using Autofac;
using PlanTempus.Components.Users.Create;
using PlanTempus.Core.CommandQueries;
namespace PlanTempus.Components;
public class CommandHandler(IComponentContext context) : ICommandHandler
{
public async Task<TCommandResult> Handle<TCommand, TCommandResult>(TCommand command)
public async Task<CommandResponse> Handle<TCommand>(TCommand command) where TCommand : ICommand
{
var handler = context.Resolve<ICommandHandler<TCommand, TCommandResult>>();
var handler = context.Resolve<ICommandHandler<TCommand>>();
return await handler.Handle(command);
}
}