Exemplo n.º 1
0
 public async Task Handle(OutgoingInvoiceLinkedToJobOrderEvent message)
 {
     using (var ctx = new AccountancyDbContext(Options))
     {
         var invoice = ctx.OutgoingInvoices.Where(i => i.OriginalId == message.InvoiceId).Single();
         invoice.JobOrderId = message.JobOrderId;
         await ctx.SaveChangesAsync();
     }
 }
 public void Handle(OutgoingInvoiceLinkedToJobOrderEvent message)
 {
     using (var ctx = new AccountancyContext())
     {
         var invoice = ctx.OutgoingInvoices.Where(i => i.OriginalId == message.InvoiceId).Single();
         invoice.JobOrderId = message.JobOrderId;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 3
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>
        /// <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 LinkOutgoingInvoice(IEventStore eventStore, Guid invoiceId, DateTime dateOfLink, decimal amount, Guid userId)
        {
            if (this.IsCompleted)
            {
                throw new InvalidOperationException("Can't relate new revenues to a completed job order");
            }
            var @event = new OutgoingInvoiceLinkedToJobOrderEvent(invoiceId, this.Id, dateOfLink, amount, userId);

            RaiseEvent(@event);
        }
Exemplo n.º 4
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 LinkOutgoingInvoice(IEventStore eventStore, Guid invoiceId, DateTime dateOfLink, decimal amount)
        {
            if (this.IsCompleted)
            {
                throw new InvalidOperationException("Can't relate new revenues to a completed job order");
            }
            var count = eventStore.Find <OutgoingInvoiceLinkedToJobOrderEvent>(e => e.InvoiceId == invoiceId && e.JobOrderId == this.Id).Count();

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

            RaiseEvent(@event);
        }
Exemplo n.º 5
0
 public void ApplyEvent(OutgoingInvoiceLinkedToJobOrderEvent evt)
 {
     this.Balance += evt.Amount;
 }
Exemplo n.º 6
0
 public void ApplyEvent([AggregateId(nameof(OutgoingInvoiceLinkedToJobOrderEvent.JobOrderId))] OutgoingInvoiceLinkedToJobOrderEvent evt)
 {
     this.Balance += evt.Amount;
 }