Пример #1
0
        public void MarkAsOverdue()
        {
            if (!DueDate.HasValue)
            {
                throw new InvalidOperationException("An invoice must have a due date for it to be marked as expired.");
            }

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

            RaiseEvent(evt);
        }
Пример #2
0
 public async Task Handle(IncomingInvoiceGotOverdueEvent message)
 {
     using (var ctx = new AccountancyDbContext(Options))
     {
         var invoice = ctx.IncomingInvoices
                       .Where(i => i.OriginalId == message.InvoiceId)
                       .Single();
         invoice.IsOverdue = true;
         await ctx.SaveChangesAsync();
     }
 }
Пример #3
0
 public void ApplyEvent([AggregateId(nameof(IncomingInvoiceGotOverdueEvent.InvoiceId))] IncomingInvoiceGotOverdueEvent evt)
 {
     IsOverdue = true;
 }