Beispiel #1
0
        public async Task <IActionResult> AddAsync(string id)
        {
            Product p = _productClient.GetProductById(id);

            _cart.Add(p.Id, p.Name, p.Price, p.Photo);
            if (_userClient.IsSignedIn())
            {
                await _userClient.UpdateAsync(_userClient.GetCurrentUser());

                User user = _userClient.GetCurrentUser();
                _logClient.SaveLog(user.Username, user.Username + " add product " + p.Name + " to cart successfully!");
                return(RedirectToAction("Index", "Cart"));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> AddAsync(string id)
        {
            Product p = _productClient.GetProductById(id);

            _cart.Add(p.Id, p.Name, p.Price, p.Photo);
            if (_userClient.IsSignedIn())
            {
                await _userClient.UpdateAsync(_userClient.GetCurrentUser());

                return(RedirectToAction("Index", "Cart"));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }