Esempio n. 1
0
        public async Task <bool> UpdateCartItemQuantityAsync(long userID, long cartItemID, XUpdateCartItemQuantityRequest request)
        {
            var httpClient = mHttpClientFactory.CreateClient(nameof(CartHttpClient));

            var body = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");

            using (var response = await httpClient.PatchAsync($"{mOptions.CartServiceBaseUrl}/Api/Internal/Carts/ByUserID/{userID}/CartItems/{cartItemID}", body))
            {
                // Normally, you would log appropriate errors and return proper error code here instead of true/false.
                return(response.IsSuccessStatusCode);
            }
        }
 public async Task <bool> UpdateCartItemQuantityAsync(long userID, long cartItemID, XUpdateCartItemQuantityRequest request)
 {
     return(await mCartService.UpdateCartItemQuantityAsync(userID, cartItemID, request.Quantity.Value));
 }
        public async Task <IActionResult> UpdateCartItemQuantity([FromRoute] long userID, [FromRoute] long cartItemID, [FromBody] XUpdateCartItemQuantityRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!await mCartService.UpdateCartItemQuantityAsync(userID, cartItemID, request.Quantity.Value))
            {
                return(NotFound());
            }

            return(Ok());
        }