Пример #1
0
        public async Task <IActionResult> AddProductToBasketAsync(string productName)
        {
            var     userId  = Int32.Parse(httpcontext.HttpContext.User.FindFirst("Id").Value);
            Product product = await customerService.SearchProductByNameAsync(productName);

            if (product == null)
            {
                return(NotFound("Product with given name has not found"));
            }

            if (product.NumberOfProducts < 1)
            {
                return(NotFound("Product is not in stock"));
            }

            await customerService.AddProductToBasketAsync(product, userId);

            return(Ok());
        }