예제 #1
0
 public async Task Handle(RetryMail command, IAggregateRepository repository)
 {
     var mail = new Mail();
     var load = await repository.Get();
     mail.LoadFromHistory(load.List);
     mail.RetryMail();
     await repository.Update(mail.RaiseNewEvents(), load.LastEventNumber);
     await mail.SendMail(this.mailService);
     await repository.Update(mail.RaiseNewEvents());
 }
예제 #2
0
 public async Task Handle(SendMail command, IAggregateRepository repository)
 {
     var mail = new Mail();
     mail.RequestMail(command);
     await repository.Create(mail.RaiseNewEvents());
     await mail.SendMail(this.mailService);
     await repository.Update(mail.RaiseNewEvents());
 }
예제 #3
0
        public async Task Handle(AddBidCommand command)
        {
            var auction = await _auctionRepository.Find(command.Id);

            if (auction is null) // Todo: in case of asynchornous command handling - should this validation be moved to the command initiator (i.e. API)?
            {
                throw new InvalidOperationException($"auction id: {command.Id} not found");
            }

            auction.AddBid(command.ItemId, command.Bidder, command.Amount, command.BidTimestamp);

            await _auctionRepository.Update(auction);
        }
예제 #4
0
        public async Task Handle(ICommand <PlaceOrder> command)
        {
            var cmd = command.Payload;

            await repository.Update(cmd.SaleId, s => s.PlaceOrder(cmd.Order));
        }