Esempio n. 1
0
        public async Task Handle(PurchaseClosedEvent notification, CancellationToken cancellationToken)
        {
            Purchase purchase = await _purchaseRepository.FindAsync(notification.AggregateId);

            foreach (PurchaseItem purchaseItem in purchase.Items)
            {
                Movement movement = await SearchMovement(purchaseItem.Product);

                MovementItem movementItem = FactoryMovementItem(purchaseItem.Amount, movement);

                await _movementService.AddItemAsync(movement, movementItem);
            }
        }