Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public void RetryProductDiscussionRequest(RetryProductDiscussionRequestCommand command)
        {
            var processId = ProcessId.ExistingProcessId(command.ProcessId);
            var tenantId  = new TenantId(command.TenantId);
            var product   = this.productRepository.GetByDiscussionInitiationId(tenantId, processId.Id);

            if (product == null)
            {
                throw new InvalidOperationException(
                          string.Format("Unknown product of tenant id: {0} and discussion initiation id: {1}.", command.TenantId, command.ProcessId));
            }

            RequestProductDiscussionFor(product);
        }
Exemplo n.º 3
0
        public void TimeOutProductDiscussionRequest(TimeOutProductDiscussionRequestCommand command)
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                var processId = ProcessId.ExistingProcessId(command.ProcessId);

                var tenantId = new TenantId(command.TenantId);

                var product = this.productRepository.GetByDiscussionInitiationId(tenantId, processId.Id);

                SendEmailForTimedOutProcess(product);

                product.FailDiscussionInitiation();

                this.productRepository.Save(product);

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