public CommandResult GetDelayedCommandResult() { if (_innerOkResult == null || !_innerOkResult.HasDelayedContent) { return(GetCommandResultFromCommandHandlerResult(_innerOkResult)); } _innerOkResult.ResolveAndUpdateDelayedContent(); return(GetCommandResultFromCommandHandlerResult(_innerOkResult)); }
public async Task <CommandResult> SendAsync <TCommand>(TCommand command) where TCommand : ICommand { try { var innerHandler = (IHandleCommand <TCommand>) _scope.ResolveOptional(typeof(IHandleCommand <TCommand>)); if (innerHandler != null) { command.Validate(); if (command.IsValid) { _innerOkResult = await innerHandler.HandleAsync(command); if (_innerOkResult == null || !_innerOkResult.HasDelayedContent) { return(GetCommandResultFromCommandHandlerResult(_innerOkResult)); } _innerOkResult.ResolveAndUpdateDelayedContent(); return(GetCommandResultFromCommandHandlerResult(_innerOkResult)); } else { return(CommandResult.FromValidationErrors(command.ValidationErrorMessages)); } } return(CommandResult.NonExistentCommand(typeof(TCommand).Name)); } catch (SecurityException ex) { return(new CommandResult(ex, HttpStatusCode.Forbidden)); } catch (Exception ex) { return(new CommandResult(ex, HttpStatusCode.InternalServerError)); } }