Пример #1
0
        public ActionResult AddItemToCart(ItemCartViewModel itemCart)
        {
            string         userLogged = _userManager.GetUserName(HttpContext.User);
            CustomerEntity loggedUser = _appService.GetLoggedCustomer(userLogged);

            int orderId;

            if (String.IsNullOrEmpty(Request.Cookies["cartStatus"]))
            {
                orderId = _cartService.CreateNewCartOrder(loggedUser, itemCart);
            }
            else
            {
                orderId = _cartService.AddItemToExistCart(loggedUser, itemCart);
            }

            Response.Cookies.Append("cartStatus", "tempCart");
            Response.Cookies.Append("orderId", orderId.ToString());

            return(RedirectToAction("Cart", orderId));
        }