コード例 #1
0
        public async Task <Unit> Handle(UpdateBasketCommand request, CancellationToken cancellationToken)
        {
            var products = request.Items.Select(x => new KeyValuePair <int, int>(x.ProductId, x.Quantity)).ToList();

            await _mediator.Publish(new CheckStockEvent(products), cancellationToken);

            var basket = new Basket(request.CustomerId);

            basket.AddBasketItems(request.Items.Select(x => x.Map <BasketItem>()).ToList());

            await _basketRepository.UpdateBasketAsync(basket);

            return(Unit.Value);
        }