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); }
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(); } }
public void ApplyEvent([AggregateId(nameof(OutgoingInvoiceOverdueEvent.InvoiceId))] OutgoingInvoiceOverdueEvent evt) { IsOverdue = true; }