コード例 #1
0
        public void Handle(OrderItemQuantityAdded message)
        {
            OrderLineReadView orderLine = db.OrderLineViews.FirstOrDefault(l => l.OrderId == message.OrderId && l.ProductId == message.ProductNumber);

            if (orderLine == null)
            {
                return;
            }

            WarehouseItemReadView warehouse = db.WarehouseItemReadViews.FirstOrDefault(l => l.WarehouseId == orderLine.WarehouseId && l.ProductId == message.ProductNumber);

            if (warehouse != null)
            {
                warehouse.Quantity -= message.Quantity;
                db.SaveChanges();
            }
        }
コード例 #2
0
        public void Handle(OrderLineAdded message)
        {
            if (!IsOrderExist(message.OrderId))
            {
                return;
            }
            var orderView = new OrderLineReadView
            {
                OrderId     = message.OrderId,
                Status      = message.Status,
                ProductId   = message.ProductNumber,
                WarehouseId = message.WarehouseId,
                Quantity    = message.Quantity
            };

            db.OrderLineViews.Add(orderView);
            db.SaveChanges();
        }