public async Task <IActionResult> Update([FromRoute] string id, [FromBody] UpdateAuctionViewModel viewModel)
        {
            var auctionId = IdentityBase.FromExistingId <AuctionId>(id);
            var command   = new UpdateAuctionCommand(auctionId, viewModel.Name, viewModel.AuctionDate);
            await _commandBus.ExecuteAsync(command);

            return(Ok());
        }
        public async Task WhenUpdateAuctionCommandIsHandledThenReturnsSuccessfulResult()
        {
            var command = new UpdateAuctionCommand(_auction.Id, "something", DateTimeOffset.UtcNow);

            var result = await _handler.HandleAsync(command);

            Assert.True(result.WasSuccessful);
        }
Exemplo n.º 3
0
 public async Task <IActionResult> Update(int id, UpdateAuctionCommand command)
 {
     if (id != command.ID)
     {
         return(BadRequest());
     }
     return(Ok(await Mediator.Send(command)));
 }
        public async Task WhenUpdateAuctionCommandIsHandledThenAuctionIsUpdated()
        {
            var auctionDate = DateTimeOffset.UtcNow;
            var command     = new UpdateAuctionCommand(_auction.Id, "something", auctionDate);

            await _handler.HandleAsync(command);

            var @event = (AuctionUpdatedEvent)_eventStore.GetLastEvent(_auction.Id);

            Assert.Equal("something", @event.Name);
            Assert.Equal(auctionDate, @event.AuctionDate);
        }
 public async Task Put([FromForm] UpdateAuctionCommand command) => await mediator.Send(command);