예제 #1
0
        public Task Handle(Print command, IMessageContext context)
        {
            if (Data.IdempotencyToken == command.IdempotencyToken)
            {
                return(CompletedTask);
            }

            var orderId          = command.AggregateId;
            var billingAccountId = command.BillingAccountId;
            var catalogId        = command.CatalogId;
            var quantity         = command.Quantity;
            var printJobQueued   = new PrintJobQueued(orderId,
                                                      billingAccountId,
                                                      catalogId,
                                                      quantity,
                                                      command.CertificateThumbprint,
                                                      command.IdempotencyToken);

            Record(printJobQueued);

            var reservations = new List <ReserveToken>();

            for (var i = 0; i < quantity; i++)
            {
                reservations.Add(new ReserveToken(orderId, billingAccountId, catalogId));
            }

            return(context.Send(reservations));
        }
예제 #2
0
 void Apply(PrintJobQueued @event)
 {
     Data.Id                    = @event.AggregateId;
     Data.State                 = Queued;
     Data.BillingAccountId      = @event.BillingAccountId;
     Data.CatalogId             = @event.CatalogId;
     Data.QuantityRequested     = @event.Quantity;
     Data.CertificateThumbprint = @event.CertificateThumbprint;
     Data.IdempotencyToken      = @event.IdempotencyToken;
 }