public void IfBidIsHigherThanPreviousBidsThenBidPlacedIsRaised() { var createAuctionCommand = Command.Create(_aggregateId, _createAuction); _subject.HandleCommand(createAuctionCommand); var placeBidCommand = Command.Create(_aggregateId, _placeBid); _subject.HandleCommand(placeBidCommand); var result = _subject.HandleCommand(Command.Create(_aggregateId, PlaceBid.Create(Bid.Create(11.5m)))); Assert.True(result is CommandResultSuccess); var newEvent = (result as CommandResultSuccess).Events.Single(); Assert.True(newEvent is BidPlaced); Assert.Equal(11.5m, (newEvent as BidPlaced).Bid.Amount); }
public ActionResult Place([FromBody] PlaceBidDto dto) { Console.WriteLine("Bid: " + JsonConvert.SerializeObject(dto)); if (!ModelState.IsValid) { return(BadRequest()); } var bid = Bid.Create(dto.Amount); var placeBid = PlaceBid.Create(bid); var command = Command.Create(dto.Id, placeBid); var result = _commandHandler.HandleCommand(command); switch (result) { case CommandResultSuccess _: return(Ok()); default: return(Conflict()); } }