Esempio n. 1
0
        private async Task DeleteProduct(int productID, CancellationToken cancellationToken)
        {
            var product = await _dbContext.Products.FindAsync(productID);

            _dbContext.Products.Remove(product);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 2
0
        public async Task Handle(OrderUpdatedV1Notification notification, CancellationToken cancellationToken)
        {
            var referencedProductIds = notification.OrderItems.Select(i => i.ProductID).ToArray();

            var products = await _dbContext.Products.Where(i => referencedProductIds.Contains(i.ID) && i.HasOrders == false).ToListAsync(cancellationToken);

            foreach (var product in products)
            {
                product.HasOrders = true;
            }

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 3
0
        private async Task CreateProduct(Product product, CancellationToken cancellationToken)
        {
            _dbContext.Products.Add(product);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 4
0
        private async Task UpdateProduct(Product product, CancellationToken cancellationToken)
        {
            _dbContext.Update(product);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }