Ejemplo n.º 1
0
        public JsonResult getShopCart()
        {
            V308CMSEntities   mEntities         = new V308CMSEntities();
            AccountRepository accountRepository = new AccountRepository(mEntities);
            ProductRepository productRepository = new ProductRepository(mEntities);

            try
            {
                ShopCart mShopCart;
                if (Session["ShopCart"] != null)
                {
                    mShopCart = (ShopCart)Session["ShopCart"];
                    return(Json(new { code = 1, count = 1, totalprice = String.Format("{0: 0,0}", (mShopCart.getTotalPrice())), message = "Không tìm thấy sản phẩm.", html = V308HTMLHELPER.createShopCart(mShopCart) }));
                }
                else
                {
                    return(Json(new { code = 0, count = 1, totalprice = 0, message = "Không tìm thấy sản phẩm." }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { code = 0, count = 1, totalprice = 0, message = "Có lỗi xảy ra. Vui lòng thử lại." }));
            }
            finally
            {
                mEntities.Dispose();
                accountRepository.Dispose();
            }
        }