Beispiel #1
0
        public IActionResult AddToCart(int bookId, int quantity)
        {
            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            _cartService.AddBookToCart(bookId, userId, quantity);
            return(RedirectToAction("Index", "Home"));
        }
Beispiel #2
0
        public int AddBookToCart(int id)
        {
            CartService service = new CartService();

            service.AddBookToCart(id, User.Identity.Name);
            return(service.GetItemsCount(User.Identity.Name));
        }
Beispiel #3
0
        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));
        }