Exemplo n.º 1
0
        public async Task ExecuteAsync(HookType type, IDomainEntityContext <Invoice> context, CancellationToken cancellationToken)
        {
            var isStatusPropertyDirty = context.EditMode == EditMode.Create ||
                                        context.EditMode == EditMode.Update && context.IsPropertyDirty(x => x.Status);

            if (isStatusPropertyDirty)
            {
                switch (context.Entity.Status)
                {
                case InvoiceStatus.Sent:
                    await context.AddEventAsync(InvoiceSentEvent.Create(_correlationIdProvider.Id, context.Entity.Id), cancellationToken);

                    break;

                case InvoiceStatus.Paid:
                    await context.AddEventAsync(InvoicePaidEvent.Create(_correlationIdProvider.Id, context.Entity.Id), cancellationToken);

                    break;

                case InvoiceStatus.Cancelled:
                    await context.AddEventAsync(InvoiceCancelledEvent.Create(_correlationIdProvider.Id, context.Entity.Id), cancellationToken);

                    break;
                }
            }
        }
Exemplo n.º 2
0
        public void Handle(InvoicePaidEvent evt)
        {
            _logger.LogInformation(GetLogMessage("Invoice Paid Event Triggered"));

            Parallel.Invoke(new List <Action>
            {
                () => InvoicePaidSendAgencyOwnerEmail(evt.InvoiceId),
                () => InvoicePaidSendCustomerEmail(evt.InvoiceId),
                () => InvoicePaidSendAccountManagerEmail(evt.InvoiceId)
            }.ToArray());
        }