private void Apply(BidPlaced @event) { this.WinningBid = new Bid() { Amount = @event.Amount, BidderId = @event.BidderId, OfferDateTime = @event.OfferDateTime }; }
public static Order CreateOpened(BidPlaced bidPlaced) { return new Order() { Type = OrderType.Bid, OrderPrice = Domain.Price.CreateUsd(bidPlaced.Price), UserId = bidPlaced.UserId, Quantity = bidPlaced.Quantity, CoinId = bidPlaced.CoinId, CreatedAt = bidPlaced.CreatedAt, Status = OrderStatus.Opened }; }
public static CommandResult Handle(State state, PlaceBid placeBid) { switch (state) { case CreatedState created: if (DateTime.UtcNow >= created.EndTime) { CommandResultFailure.Create("Auction has finished"); } if (placeBid.Bid.Amount <= created.HighestBid) { CommandResultFailure.Create("Bid is not higher than current highest bid"); } var bidPlaced = BidPlaced.Create(placeBid.Bid); return(CommandResultSuccess.Create(new List <EventPayload> { bidPlaced })); default: return(CommandResultFailure.Create("Auction not created")); } }
private void OnBidPlaced(BidPlaced ev) { this.Bids[ev.Bid.Id] = ev.Bid; this.HigherBid = ev.Bid; }
public Task Handle(BidPlaced message, IMessageHandlerContext context) { return(Task.CompletedTask); }
void Apply(BidPlaced @event) { _bids.Add(new BidInfo { Amount = @event.Amount, BidId = @event.BidId }); }
public void Handle(BidPlaced bidPlaced) { _dbAccess.Add(Order.CreateOpened(bidPlaced)); }
private void When(BidPlaced @event) { this.WinningBid = new WinningBid(@event.BidderId, @event.BidAmount); }
public void When(BidPlaced @event) { WinningBid = new WinningBid(@event.BidderId, @event.BidAmout); }
public async Task <Unit> Handle(CreateBidCommand request, CancellationToken cancellationToken) { await _messageBroker.Publish(BidPlaced.CreateFrom(request)); return(Unit.Value); }