public CommandExecutionResult CheckContext(IBaseCommand command) { var result = new CommandExecutionResult(this.teclyn); this.CheckContextInternal(command, result); return(result); }
public async Task <ICommandResult> Execute <TCommand>(TCommand command) where TCommand : ICommand { var commandHandler = this._dependencyResolver.Get <ICommandHandler <TCommand> >(); var result = new CommandExecutionResult(this._dependencyResolver); var success = await commandHandler.CheckContext(command, this._context, result) && await commandHandler.CheckParameters(command, result) && await this.ExecuteCommandHandler(command, commandHandler, result); return(result); }
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); }
public UserFriendlyCommandResult(CommandExecutionResult result) { this.Success = result.Success; this.Errors = result.Errors.ToArray(); }
private void CheckContextInternal(IBaseCommand command, CommandExecutionResult result) { result.ContextIsValid = command.CheckContext(context, result); }
private void CheckParametersInternal(IBaseCommand command, CommandExecutionResult result) { result.ParametersAreValid = command.CheckParameters(result); }
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); } }