
Untitled
By: a guest on
May 16th, 2012 | syntax:
None | size: 0.58 KB | hits: 12 | expires: Never
public class InvokeCommandAction<TEntity, TCommand>
where TEntity : IAggregate
where TCommand : class, ICommand<TEntity>
{
private readonly ICommandInvoker _invoker;
public InvokeCommandAction(ICommandInvoker invoker)
{
_invoker = invoker;
}
public CommandResult<TEntity> Execute(TCommand command)
{
var result = new CommandResult<TEntity>
{
AggregateId = command.Id,
Success = true
};
try
{
_invoker.Invoke(command);
}
catch (Exception exc)
{
result.Success = false;
result.RegisterError(exc.Message);
}
return result;
}
}