Esempio n. 1
0
        private async Task DeleteOrder(int orderID, CancellationToken cancellationToken)
        {
            var order = await _dbContext.Orders.FindAsync(orderID);

            _dbContext.Orders.Remove(order);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 2
0
        public async Task Handle(ProductDeletedV1Notification notification, CancellationToken cancellationToken)
        {
            var product = await _dbContext.Products.SingleOrDefaultAsync(i => i.ID == notification.ID, cancellationToken);

            if (product == null)
            {
                return;
            }

            _dbContext.Products.Remove(product);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 3
0
        public async Task Handle(CustomerDeletedV1Notification notification, CancellationToken cancellationToken)
        {
            var customer = await _dbContext.Customers.SingleOrDefaultAsync(i => i.ID == notification.ID, cancellationToken);

            if (customer == null)
            {
                return;
            }

            _dbContext.Customers.Remove(customer);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 4
0
        public async Task Handle(ProductCreatedV1Notification notification, CancellationToken cancellationToken)
        {
            var product = await _dbContext.Products.SingleOrDefaultAsync(i => i.ID == notification.ID, cancellationToken);

            if (product != null)
            {
                return;
            }

            _dbContext.Products.Add(new Product {
                ID = notification.ID
            });

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 5
0
        private async Task CreateOrder(Order order, CancellationToken cancellationToken)
        {
            _dbContext.Orders.Add(order);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 6
0
        private async Task CreateOrderItem(OrderItem orderItem, CancellationToken cancellationToken)
        {
            _dbContext.OrderItems.Add(orderItem);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 7
0
        private async Task UpdateOrder(Order order, CancellationToken cancellationToken)
        {
            _dbContext.Update(order);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }
Esempio n. 8
0
        private async Task UpdateOrderItem(UpdateOrderItemV1Command request, CancellationToken cancellationToken)
        {
            _dbContext.Update(request.OrderItem);

            await _dbContext.SaveChangesAsync(cancellationToken);
        }