Example #1
0
        public async Task <IActionResult> Logout()
        {
            var user = await _userManager.FindByNameAsync(HttpContext.User.Identity.Name);

            var id = _userRepository.GetUserFromIdentity(user.Id); // get userID from CoPartDB

            await _signInManager.SignOutAsync();

            _logger.LogInformation("User logged out.");

            // save cart when logout
            _transactionItems.SaveCartToDB(id);

            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
Example #2
0
        public async Task <IActionResult> SaveLogout()
        {
            var user = HttpContext.User.Identity.Name;

            if (user == null)
            {
                return(RedirectToAction("AuthorizeIndex"));
            }
            var id = await GetUserId();

            _transactionItems.SaveCartToDB(id);
            await _signInManager.SignOutAsync();

            return(RedirectToAction(nameof(HomeController.Index), "Home"));
            //return RedirectToRoute("{controller=Account}/{action=Logout}");
        }
Example #3
0
        public async Task <IActionResult> SaveCart()
        {
            var user = HttpContext.User.Identity.Name;

            if (user == null)
            {
                return(Ok());
            }

            var currentuser = await _userManager.FindByNameAsync(HttpContext.User.Identity.Name).ConfigureAwait(false);

            var id = _userRepository.GetUserFromIdentity(currentuser.Id);

            _transactionItems.SaveCartToDB(id);
            return(Ok());
        }