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