public async Task Handle(StockPurchased e, CancellationToken cancellationToken) { var s = await _storage.GetStock(e.Ticker, e.UserId); if (s == null) { return; } var when = e.When; var notes = e.Notes; var ticker = e.Ticker; await CreateNote(e.UserId, when, notes, ticker); }
internal void Apply(StockPurchased purchased) { this.AverageCost = (this.AverageCost * this.Owned + purchased.Price * purchased.NumberOfShares) / (this.Owned + purchased.NumberOfShares); Owned += purchased.NumberOfShares; Cost = AverageCost * Owned; LastPurchase = purchased.When; this.Buys.Add(purchased); this.Transactions.Add(Transaction.DebitTx( this.Ticker, $"Purchased {purchased.NumberOfShares} shares @ ${purchased.Price}/share", purchased.Price * purchased.NumberOfShares, purchased.When, false )); }
internal void ApplyInternal(StockPurchased purchased) { BuyOrSell.Add(purchased); StateUpdateLoop(); }
private void ApplyInternal(StockPurchased purchased) { this.State.Apply(purchased); }