public void Handle(LinkOutgoingInvoiceToJobOrderCommand message)
        {
            var jobOrder = Repository.GetById <TimeAndMaterialJobOrder>(message.JobOrderId);

            jobOrder.LinkOutgoingInvoice(EventStore, message.InvoiceId, message.DateOfLink, message.Amount);
            Repository.Save(jobOrder);
        }
Beispiel #2
0
 public Task Handle(LinkOutgoingInvoiceToJobOrderCommand message)
 {
     return(Task.Factory.StartNew(() =>
     {
         var jobOrder = _repository.GetById <JobOrder>(message.JobOrderId);
         jobOrder.LinkOutgoingInvoice(_eventStore, message.InvoiceId, message.DateOfLink, message.Amount);
         _repository.Save(jobOrder);
     }));
 }
        public void LinkOutgoingInvoiceToJobOrder(LinkOutgoingInvoiceToJobOrderViewModel model)
        {
            var jobOrderId = (from j in Database.JobOrders
                              where j.Number == model.JobOrderNumber
                              select j.OriginalId).Single();
            var command = new LinkOutgoingInvoiceToJobOrderCommand(model.InvoiceOriginalId, jobOrderId, model.DateOfLink, model.Amount);

            Bus.Send(command);
        }
Beispiel #4
0
        public async Task LinkOutgoingInvoiceToJobOrderAsync(LinkOutgoingInvoiceToJobOrderModel model)
        {
            var command = new LinkOutgoingInvoiceToJobOrderCommand(
                model.UserId,
                model.InvoiceId,
                model.JobOrderId,
                model.DateOfLink,
                model.Amount
                );

            await Bus.Send(command);
        }
Beispiel #5
0
        public async Task Handle(LinkOutgoingInvoiceToJobOrderCommand message)
        {
            var count = eventStore.Find <OutgoingInvoiceLinkedToJobOrderEvent>(e => e.InvoiceId == message.InvoiceId && e.JobOrderId == message.JobOrderId).Count();

            if (count > 0)
            {
                throw new InvalidOperationException("The specified invoice is already associated to a Job Order.");
            }
            var jobOrder = repository.GetById <JobOrder>(message.JobOrderId);

            jobOrder.LinkOutgoingInvoice(eventStore, message.InvoiceId, message.DateOfLink, message.Amount);
            await repository.SaveAsync(jobOrder);
        }