Esempio n. 1
0
        public void MarkAsOverdue(Guid userId)
        {
            if (!DueDate.HasValue)
            {
                throw new InvalidOperationException("An invoice must have a due date for it to be marked as expired.");
            }

            var evt = new OutgoingInvoiceGotOverdueEvent(this.Id, DueDate.Value, userId);

            RaiseEvent(evt);
        }
 public async Task Handle(OutgoingInvoiceGotOverdueEvent message)
 {
     using (var ctx = new AccountancyDbContext(Options))
     {
         var invoice = ctx.OutgoingInvoices
                       .Where(i => i.OriginalId == message.InvoiceId)
                       .Single();
         invoice.IsOverdue = true;
         await ctx.SaveChangesAsync();
     }
 }
Esempio n. 3
0
 public void ApplyEvent([AggregateId(nameof(OutgoingInvoiceGotOverdueEvent.InvoiceId))] OutgoingInvoiceGotOverdueEvent evt)
 {
     IsOverdue = true;
 }