Ejemplo n.º 1
0
 public async Task Handle(IncomingInvoiceLinkedToJobOrderEvent message)
 {
     using (var ctx = new AccountancyDbContext(Options))
     {
         var invoice = ctx.IncomingInvoices.Where(i => i.OriginalId == message.InvoiceId).Single();
         invoice.JobOrderId = message.JobOrderId;
         await ctx.SaveChangesAsync();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Associate an incoming invoice to the current Job Order
        /// </summary>
        /// <param name="eventStore">The event store</param>
        /// <param name="invoiceId">The Id of the Invoice to be associated to the current Job Order</param>
        /// <param name="userId">The Id of the current user</param>
        /// <exception cref="InvalidOperationException">Thrown if the specified invoiceId refers to an invoice which has already been associated to a Job Order</exception>
        public void LinkIncomingInvoice(IEventStore eventStore, Guid invoiceId, DateTime dateOfLink, decimal amount, Guid userId)
        {
            if (this.IsCompleted)
            {
                throw new InvalidOperationException("Can't relate new costs to a completed job order");
            }
            var @event = new IncomingInvoiceLinkedToJobOrderEvent(invoiceId, this.Id, dateOfLink, amount, userId);

            RaiseEvent(@event);
        }
Ejemplo n.º 3
0
 public void ApplyEvent(IncomingInvoiceLinkedToJobOrderEvent evt)
 {
     this.Balance -= evt.Amount;
 }