示例#1
0
        public async Task <IActionResult> Index()
        {
            List <CategoryViewModel> categoryList = await _categoryApiClient.GetList();

            ViewBag.CategoryList = categoryList;
            ViewBag.Url          = _configuration["BaseAddress"];

            cart = SessionExtensions.Get <List <CartItems> >(HttpContext.Session, "cart");
            var list = new List <CartItems>();

            if (cart != null)
            {
                list = cart;
            }
            ViewBag.Cart = list;


            decimal total = 0;

            foreach (var item in list)
            {
                total += (item.Price * item.Quantity);
            }
            ViewBag.total = total;

            return(View(list));
        }
        public async Task <IActionResult> Index()
        {
            var data = await _categoryApiClient.GetList();

            if (TempData["result"] != null)
            {
                ViewBag.SuccessMsg = TempData["result"];
            }
            return(View(data));
        }
        public async Task <IActionResult> Index(string keyword, int categoryId, int pageIndex = 1, int pageSize = 6)
        {
            var request = new GetProductByCategoryPagingRequest()
            {
                CategoryId = categoryId,
                Keyword    = keyword,
                PageIndex  = pageIndex,
                PageSize   = pageSize
            };

            List <CategoryViewModel> categoryList = await _categoryApiClient.GetList();

            ViewBag.CategoryList = categoryList;

            List <CartItems> cart = SessionExtensions.Get <List <CartItems> >(HttpContext.Session, "cart");
            var list = new List <CartItems>();

            if (cart != null)
            {
                list = cart;
            }
            ViewBag.Cart = list;

            decimal total = 0;

            foreach (var item in list)
            {
                total += (item.Price * item.Quantity);
            }
            ViewBag.total = total;

            var data = await _productApiClient.GetProductPagings(request);

            ViewBag.Keyword = keyword;
            ViewBag.Url     = _configuration["BaseAddress"];

            return(View(data));
        }
        public async Task <IActionResult> Index(string keyword, int pageIndex = 1, int pageSize = 10)
        {
            var request = new GetProductPagingRequest()
            {
                Keyword   = keyword,
                PageIndex = pageIndex,
                PageSize  = pageSize
            };
            var data = await _productApiClient.GetProductPagings(request);

            List <CategoryViewModel> categoryList = await _categoryApiClient.GetList();

            //SelectList cateList = new SelectList(categoryList, "Id", "Name");

            ViewBag.CategoryList = categoryList;

            ViewBag.Url     = _configuration["BaseAddress"];
            ViewBag.Keyword = keyword;
            if (TempData["result"] != null)
            {
                ViewBag.SuccessMsg = TempData["result"];
            }
            return(View(data));
        }