コード例 #1
0
        internal void AddNextNumber(Guid nextNumberId)
        {
            var nextNumberInRow = (this.Numbers.Any() ? this.Numbers.Max(x => x.Number) : this.InitialNumber) + 1;
            var nextNumberEvent = new AddNextNumberEvent(this.AggregateId, nextNumberId, this.CounterArea, this.Prefix,
                                                         nextNumberInRow);

            this.RaiseEvent(nextNumberEvent);
        }
コード例 #2
0
        public async Task Handle(AddNextNumberEvent notification, CancellationToken cancellationToken)
        {
            using (var connection = this._dbConnectionFactory.OpenConnection())
            {
                var runningNumberCounterRepository = new RunningNumberCounterRepository();
                var runningNumberCounterId         = notification.AggregateId;
                var runningNumberRepository        = new RunningNumberRepository();

                var runningNumber = $"{notification.Prefix}-{notification.NextNumberInRow}";
                await runningNumberRepository.CreateNewRunningNumberAsync(connection, notification.NextNumberId,
                                                                          runningNumberCounterId, runningNumber);

                await runningNumberCounterRepository.IncreaseCounterAsync(connection, runningNumberCounterId);
            }
        }
コード例 #3
0
        private void Apply(AddNextNumberEvent obj)
        {
            var nextNumber = new RunningNumber(obj.NextNumberId, obj.Prefix, obj.NextNumberInRow);

            this.Numbers.Add(nextNumber);
        }