private async Task <bool> ExecuteQueryHandler <TQuery, TResult>(TQuery command, IQueryHandler <TQuery, TResult> queryHandler, QueryExecutionResult <TQuery, TResult> result) where TQuery : IQuery <TResult> { try { var handlerResult = await queryHandler.Execute(command, result); result.SetSuccess(); result.Result = handlerResult; return(true); } catch (Exception exception) { result.SetFailure(exception.ToString()); return(false); } }
public async Task <IQueryResult <TResult> > ExecuteInternal <TQuery, TResult>(TQuery command, Func <TQuery, TResult> resultAccessor) where TQuery : IQuery { var result = new QueryExecutionResult <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); }