コード例 #1
0
        public async Task <ActionResult <Cart> > Post([FromBody] CartItemDto cartProductDto, string sessionId)
        {
            var product = await _productClient.Get(cartProductDto.ProductId);

            if (product == null)
            {
                return(BadRequest("Product does not exist."));
            }

            if (cartProductDto.Quantity < 1)
            {
                return(BadRequest("Quantity cannot be less than 0"));
            }

            var cartProduct = new CartItem(product, cartProductDto.Quantity);
            var cart        = await _cartClient.Update(sessionId, cartProduct);

            return(Ok(cart));
        }
コード例 #2
0
        public async Task <ActionResult <IEnumerable <string> > > GetAll()
        {
            var result = await _productClient.Get();

            return(Ok(result));
        }