private async Task <bool> ExecuteCommandHandler <TCommand>(TCommand command, ICommandHandler <TCommand> commandHandler, CommandExecutionResult result) where TCommand : ICommand { try { await commandHandler.Execute(command, result); result.SetSuccess(); return(true); } catch (Exception exception) { result.SetFailure(exception.ToString()); return(false); } }
public async Task <ICommandResult <TResult> > ExecuteInternal <TCommand, TResult>(TCommand command, Func <TCommand, TResult> resultAccessor) where TCommand : IBaseCommand { var result = new CommandExecutionResult <TResult>(teclyn); this.CheckContextInternal(command, result); this.CheckParametersInternal(command, result); if (!result.Errors.Any()) { // execute await command.Execute(result); // get result result.Result = resultAccessor(command); result.SetSuccess(); } return(result); }