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 IncomingInvoiceOverdueEvent(this.Id, DueDate.Value, userId); RaiseEvent(evt); }
public async Task Handle(IncomingInvoiceOverdueEvent message) { using (var ctx = new AccountancyDbContext(Options)) { var invoice = ctx.IncomingInvoices .Where(i => i.OriginalId == message.InvoiceId) .Single(); invoice.IsOverdue = true; await ctx.SaveChangesAsync(); } }
public void ApplyEvent([AggregateId(nameof(IncomingInvoiceOverdueEvent.InvoiceId))] IncomingInvoiceOverdueEvent evt) { IsOverdue = true; }