Beispiel #1
0
        public IActionResult AddToCart(int bookAdded)
        {
            var userId = _userManager.GetUserId(User);
            var cart   = _orderServices.GetCart(userId);

            //Ef karfan finnst ekki einhverra hluta vegna
            if (cart == 0)
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }

            if (!_orderServices.AddToCart(bookAdded, userId, cart))
            {
                ViewBag.Title = "Error";
                return(View("Error"));
            }
            ViewBag.Title = "Sucess!";
            return(RedirectToAction("Cart", "Order"));
        }
Beispiel #2
0
 public void AddToCart(Book book)
 {
     //add a given book to the cart
     _orderRepo.AddToCart(book, this.ShoppingCartId);
 }