public void InitiateDiscussion(InitiateDiscussionCommand command)
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                var product = _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));

                _productRepository.Save(product);

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

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

                tracker.MarkProcessCompleted();

                _processTrackerRepository.Save(tracker);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
Beispiel #2
0
        public void CheckForTimedOutProccesses()
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                var trackers = _processTrackerRepository.GetAllTimedOut();

                foreach (var tracker in trackers)
                {
                    tracker.InformProcessTimedOut();
                    _processTrackerRepository.Save(tracker);
                }

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