Esempio n. 1
0
        public IViewComponentResult Invoke()
        {
            var bookIds = CardHelper.GetAllProducts(HttpContext);
            var books   = _bookService.FindAll(bookIds);
            var total   = 0.0;

            foreach (var bookD in books)
            {
                total += bookD.Value * bookD.Key.Price;
            }
            ViewData.Model       = books;
            ViewData["quantity"] = bookIds.Count;
            ViewData["total"]    = total;

            var username = HttpContext.Session.GetString("userId");

            ViewData["username"] = null;
            if (username != null && !username.Equals(""))
            {
                ViewData["username"] = username;
            }
            return(View());
        }