Beispiel #1
0
 public async Task <IActionResult> AddToCartPost(int customerId, int productId, AddToCartViewModel item)
 {
     if (!ModelState.IsValid)
     {
         return(View(item));
     }
     try
     {
         await _webApiCalls.AddToCartAsync(customerId, productId, item.Quantity);
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, "There was an error adding the item to the cart.");
         return(View(item));
     }
     return(RedirectToAction(nameof(CartController.Index), new { customerId }));
 }