public async Task Handle(V1.AccountClosed @event, CancellationToken cancellationToken) { var clearanceDto = await clearanceDtoRepository.GetClearanceByClearanceId(@event.ClearanceId); if (clearanceDto == null) { throw new NullReferenceException("No accountDto has been found"); } var userAccount = clearanceDto.UserAccounts.Single(x => x.AccountId == @event.AccountId); userAccount.Amount = @event.Amount; userAccount.CurrencyCode = @event.CurrencyCode; await clearanceDtoRepository.Update(clearanceDto); }
public async Task Handle(V1.ClearanceFinalized @event, CancellationToken cancellationToken) { var clearanceDto = await clearanceDtoRepository.GetClearanceByClearanceId(@event.ClearanceId); if (clearanceDto == null) { throw new NullReferenceException("No accountDto has been found"); } clearanceDto.Settlement = new ClearanceDto.PaymentSettlement { Payer = @event.Payer, Receiver = @event.Receiver, Amount = @event.Amount, CurrencyCode = @event.CurrencyCode }; await clearanceDtoRepository.Update(clearanceDto); }