public IActionResult AddToCart(int bookId, int quantity) { var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier); _cartService.AddBookToCart(bookId, userId, quantity); return(RedirectToAction("Index", "Home")); }
public int AddBookToCart(int id) { CartService service = new CartService(); service.AddBookToCart(id, User.Identity.Name); return(service.GetItemsCount(User.Identity.Name)); }
public ActionResult AddBooksToCart(int id, int count) { CartService service = new CartService(); CartViewModel cartVM = new CartViewModel(); if (User.Identity.IsAuthenticated) { cartVM = service.AddBookToCart(id, User.Identity.Name, count); Hubs.HubAccessor.Instance.UpdateBookCounter(id, cartVM.BooksCount); } else { cartVM.ErrorMessage = "Aby kontynuować musisz się zalogować."; } return(Json(cartVM, JsonRequestBehavior.AllowGet)); }