public async Task Execute(BuyStockInput input) { var wallet = await this._walletRepository.GetWalletBy(input.WalletId); if (wallet == null) { this._output.Error("Wallet not found"); return; } this._walletService.BuyStock(wallet, input.Ticker, input.Quantity, input.Amount); await this._unitOfWork.Save(); await this._eventPublisher.Publish(wallet.GetEvents()); BuildOutputPort(input, wallet); }
private void BuildOutputPort(BuyStockInput input, Wallet wallet) { var stock = wallet.Stocks.FirstOrDefault(s => s.Ticker == input.Ticker); this._output.Ok(new BuyStockOutput(stock)); }