Esempio n. 1
0
        public ActionResult ProductCategoryMenu()
        {
            var productCategory = _productCategoryService.ListAllOrderByCreateDate();
            var model           = productCategory.Select(item => new ProductCategoryViewModels(item)).ToList();

            ViewBag.ContentCategory = _contentCategoryService.ListAllDisplayOrder();
            ViewBag.MenuType        = _menuTypeService.ListAll();
            ViewBag.Menu            = _menuService.ListAll();

            if (User.Identity.IsAuthenticated == false)
            {
                var list = new List <CartItem>();
                int i    = -1;
                while (1 != 2)
                {
                    i++;
                    HttpCookie cooki = HttpContext.Request.Cookies[i.ToString()];// lấy cookie
                    if (cooki == null)
                    {
                        break;
                    }
                    string valueCookie = Server.UrlDecode(cooki.Value);                                 //Decode dịch ngược mã  các ký tự đặc biệt tham khảo
                    var    cart2       = JsonConvert.DeserializeObject <List <CartItem> >(valueCookie); // convert json to  list object
                    var    list2       = (List <CartItem>)cart2;
                    list.AddRange(list2);
                }
                ViewBag.Cart = list;
            }
            else
            {
                var list            = new List <CartItem>();
                var orderDetailTemp = _orderDetailTempService.ListAllByUserID(User.Identity.GetUserId());
                if (orderDetailTemp != null)
                {
                    string Value = Server.UrlDecode(orderDetailTemp.CartContent);           //Decode dịch ngược mã  các ký tự đặc biệt tham khảo
                    var    cart  = JsonConvert.DeserializeObject <List <CartItem> >(Value); // convert json to  list object
                    list = (List <CartItem>)cart;
                }
                ViewBag.Cart = list;
            }


            return(PartialView(model));
        }
Esempio n. 2
0
        public ActionResult ProductCategoryMenu()
        {
            var productCategory = _productCategoryService.ListAllOrderByCreateDate();
            var model           = productCategory.Select(item => new ProductCategoryViewModels(item)).ToList();

            ViewBag.ContentCategory = _contentCategoryService.ListAllDisplayOrder();
            ViewBag.MenuType        = _menuTypeService.ListAll();
            ViewBag.Menu            = _menuService.ListAll();



            //Giỏ hàng
            var cart = ListCart.listCart;
            var list = new List <CartItem>();

            if (cart != null)
            {
                list = (List <CartItem>)cart;
            }
            ViewBag.Cart = list;


            return(PartialView(model));
        }