コード例 #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 OutgoingInvoiceOverdueEvent(this.Id, DueDate.Value, userId);

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