Example #1
0
 public ActionResult AddToCart(string values)
 {
     if (!HttpContext.User.Identity.IsAuthenticated)
     {
         return(Json(new { redirectToUrl = Url.Action("Login", "Account") }));
     }
     else
     {
         var AddToCart      = shoppingCartService.AddToCart();
         var AddToCartItems = shoppingCartService.AddToCartItems(values);
         if (AddToCart.isSuccessful && AddToCartItems.isSuccessful)
         {
             return(Json(new { redirectToUrl = Url.Action("ShopCart") }));
         }
         else
         {
             var Error = AddToCart.exception;
             ViewBag.ErrorToAddCart = Error.ToString();
             return(Json(new { redirectToUrl = Url.Action("ShopCart") }));
         }
     }
 }