Example #1
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var nextSequence = await dbContext.GetNextSequenceNumber <Product>(collectionName);

                var product = new Product()
                {
                    Name  = request.Name,
                    Price = request.Price,
                    Id    = nextSequence
                };
                var collection = dbContext.GetCollection <Product>(collectionName);
                await collection.InsertOneAsync(product);

                await dbContext.IncrementSequenceNumberAsync <Product>(collectionName);

                return(Unit.Value);
            }