Example #1
0
            public async Task <ulong> Handle(CreateOrder command, CancellationToken cancellationToken)
            {
                var order = new Order(_idGenerator.GetId());
                await _context.Orders.AddAsync(order, cancellationToken);

                await _context.SaveAsync(cancellationToken);

                return(order.Id);
            }
        public int StartNewSession(PokerUser user)
        {
            var existingSession = GetSession(user);

            if (existingSession != null)
            {
                messageSender.UserAlreadyInSession(user);
                return(0);
            }
            var newSession = new ScrumPokerSession(user, idGenerator.GetId());

            ScrumPokerSessions.Add(newSession);
            messageSender.SendStartSessionToMaster(user, newSession.Id);
            return(newSession.Id);
        }
Example #3
0
        public async Task Foo()
        {
            await using var unitOfWork = await _unitOfWorkManager.Begin("a");

            if (!unitOfWork.Outbox.IsClosed)
            {
                var id = await _idGenerator.GetId(unitOfWork.Outbox.IdempotencyId, "id-generator-account");

                // DB state updated here

                unitOfWork.Outbox.Publish(new object());
                unitOfWork.Outbox.Send(new object());
                unitOfWork.Outbox.Return(new object());

                await unitOfWork.Commit();
            }

            await unitOfWork.EnsureOutboxDispatched();
        }
Example #4
0
 public void PutForAdoption(IAnimal animal)
 {
     _animalRegistry.Add(animal.GetType().Name + "_" + _idGenerator.GetId(), animal);
 }