public IHttpActionResult DeliverOrder([FromBody] GuidModel model)
        {
            var id        = AggregateId.NewAggregateId(model.OrderId);
            var processId = FSharpOption <ProcessId> .Some(ProcessId.NewProcessId(model.ProcessId));

            var cmd      = Command.Deliver;
            var envelope = createCommand(id, AggregateVersion.Irrelevant, null, null, processId, cmd);

            QueueCommand(envelope);

            return(Ok());
        }
Exemplo n.º 2
0
        public IHttpActionResult CheckOut([FromBody] CheckOutModel model)
        {
            var basketId  = model.BasketId;
            var address   = model.ShippingAddress;
            var cmd       = Command.NewCheckOut(ShippingAddress.NewShippingAddress(address));
            var processId = FSharpOption <ProcessId> .Some(ProcessId.NewProcessId(Guid.NewGuid()));

            var envelope = createCommand(AggregateId.NewAggregateId(basketId), AggregateVersion.Irrelevant, null, null, processId, cmd);

            var basket = CommitCommand(envelope);

            return(Ok(basket));
        }
Exemplo n.º 3
0
        public void StartDiscussionInitiation(StartDiscussionInitiationCommand command)
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                var product = this.productRepository.Get(new TenantId(command.TenantId), new ProductId(command.ProductId));
                if (product == null)
                {
                    throw new InvalidOperationException(
                              string.Format("Unknown product of tenant id: {0} and product id: {1}.", command.TenantId, command.ProductId));
                }

                var timedOutEventName = typeof(ProductDiscussionRequestTimedOut).Name;

                var tracker = new TimeConstrainedProcessTracker(
                    tenantId: command.TenantId,
                    processId: ProcessId.NewProcessId(),
                    description: "Create discussion for product: " + product.Name,
                    originalStartTime: DateTime.UtcNow,
                    allowableDuration: 5L * 60L * 1000L,
                    totalRetriesPermitted: 3,
                    processTimedOutEventType: timedOutEventName);

                this.processTrackerRepository.Save(tracker);

                product.StartDiscussionInitiation(tracker.ProcessId.Id);

                this.productRepository.Save(product);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }