Example #1
0
        public async Task <IActionResult> AddProduct(ProductCreateViewModel model)
        {
            var productRequest = model.MapToRequest();

            HttpResponseMessage response = await PostAsync("products", productRequest);

            if (!response.IsSuccessStatusCode)
            {
                TempData["ProductErrorMessage"] = await response.Content.ReadAsStringAsync();
            }

            return(RedirectToAction(nameof(Index)));
        }