public async Task <IViewComponentResult> InvokeAsync() { //CardHelper.Update(HttpContext,) Dictionary <int, int> card = CardHelper.GetAllProducts(HttpContext); Dictionary <Book, int> books = _bookService.FindAll(card); return(View(books)); }
//[HttpGet("Card/AddProduct/{id}")] public async Task <IViewComponentResult> InvokeAsync() { Dictionary <int, int> bookIds = CardHelper.GetAllProducts(HttpContext); Dictionary <Book, int> books = _bookService.FindAll(bookIds); string referer = Request.Headers["Referer"].ToString(); ViewData["returnurl"] = referer; return(View(books)); }
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()); }