Пример #1
0
        public IReadModelWorkItem Enqueue(Guid aggregateId, string aggregateType, int fromVersion)
        {
            var workItem = new ReadModelWorkItem {
                AggregateType = aggregateType,
                Identity = aggregateId,
                FromVersion = fromVersion
            };

            Monitor.Enter(this.locker);
            try
            {
                var existingItem = this.repository.GetById(workItem.Identity);
                if (existingItem != null && existingItem.FromVersion < workItem.FromVersion)
                {
                    return null;
                }

                this.repository.Save((ReadModelWorkItem)workItem);
            }
            finally
            {
                Monitor.Exit(this.locker);
            }

            return workItem;
        }
Пример #2
0
        public IReadModelWorkItem Enqueue(Guid aggregateId, string aggregateType, int fromVersion)
        {
            var workItem = new ReadModelWorkItem {
                AggregateType = aggregateType,
                Identity      = aggregateId,
                FromVersion   = fromVersion
            };

            Monitor.Enter(this.locker);
            try
            {
                var existingItem = this.repository.GetById(workItem.Identity);
                if (existingItem != null && existingItem.FromVersion < workItem.FromVersion)
                {
                    return(null);
                }

                this.repository.Save((ReadModelWorkItem)workItem);
            }
            finally
            {
                Monitor.Exit(this.locker);
            }

            return(workItem);
        }