Beispiel #1
0
 public void Handle(OutgoingInvoiceAssociatedToJobOrderEvent message)
 {
     using (var ctx = new AccountancyContext())
     {
         var invoice = ctx.OutgoingInvoices.Where(i => i.OriginalId == message.InvoiceId).Single();
         invoice.JobOrderId = message.JobOrderId;
         ctx.SaveChanges();
     }
 }
Beispiel #2
0
        /// <summary>
        /// Associate an outgoing 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>
        /// <exception cref="InvalidOperationException">Thrown if the specified invoiceId refers to an invoice which has already been associated to a Job Order</exception>
        public void AssociateOutgoingInvoice(IEventStore eventStore, Guid invoiceId)
        {
            var count = eventStore.Find <OutgoingInvoiceAssociatedToJobOrderEvent>(e => e.InvoiceId == invoiceId).Count();

            if (count > 0)
            {
                throw new InvalidOperationException("The specified invoice is already associated to a Job Order.");
            }
            var @event = new OutgoingInvoiceAssociatedToJobOrderEvent(invoiceId, this.Id);

            RaiseEvent(@event);
        }
Beispiel #3
0
 public void Apply(OutgoingInvoiceAssociatedToJobOrderEvent evt)
 {
 }