public void InitiateDiscussion(InitiateDiscussionCommand 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));

                product.InitiateDiscussion(new DiscussionDescriptor(command.DiscussionId));

                this.productRepository.Save(product);

                var processId = ProcessId.ExistingProcessId(product.DiscussionInitiationId);

                var tracker = this.processTrackerRepository.Get(command.TenantId, processId);

                tracker.MarkProcessCompleted();

                this.processTrackerRepository.Save(tracker);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
Exemple #2
0
        public void InitiateDiscussion(InitiateDiscussionCommand 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));
                }

                product.InitiateDiscussion(new DiscussionDescriptor(command.DiscussionId));

                this.productRepository.Save(product);

                var processId = ProcessId.ExistingProcessId(product.DiscussionInitiationId);

                var tracker = this.processTrackerRepository.Get(command.TenantId, processId);

                tracker.MarkProcessCompleted();

                this.processTrackerRepository.Save(tracker);

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