예제 #1
0
        public async Task <IActionResult> AddToCart(int id)
        {
            AppUser user = await _userManager.GetUserAsync(User);

            Cart    cart    = _sqlCart.GetCart(user);
            Product product = _sqlProduct.GetProduct(id);

            _sqlCart.AddProductToCart(product, cart);

            return(RedirectToAction(nameof(GetAllProducts)));
        }
예제 #2
0
        public async Task <IActionResult> DeleteItem(int id)
        {
            AppUser user = await _userManager.GetUserAsync(User);

            Cart cart = _sqlCart.GetCart(user);

            var product = _sqlProduct.GetProduct(id);

            _sqlCart.DeleteProductFromCart(product, cart);

            return(RedirectToAction(nameof(cart)));
        }
예제 #3
0
 public Product GetProduct(int productID)
 {
     return(sqlProd.GetProduct(productID));
 }