Exemple #1
0
        public ActionResult AddProductToCart(AddProductToCartModel model)
        {
            if (ModelState.IsValid)
            {
                var result = _customerService.AddProductToCart(new SerializeProductInfoForCart
                {
                    Id       = model.ProductId,
                    Quantity = model.Quantity
                }, HttpContext);

                if (!result.Succedeed)
                {
                    return(RedirectToAction("Index", "Error", new ErrorViewModel {
                        ErrorMessage = result.Message
                    }));
                }

                return(RedirectToAction("Details", new { id = model.ProductId, productAdded = true }));
            }
            return(RedirectToAction("Details", new { id = model.ProductId }));
        }