public async Task <ActionResult> AuthenticateUserEmail(VMUserDetail email)
        {
            _logger.LogInformation("AuthenticateUserEmail started", new object[] { email });
            try
            {
                if (email.IsForgetPassword == 1)
                {
                    HttpContext.Session.SetString("CurrentUser", email.user_email);
                    HttpContext.Session.CommitAsync().Wait();
                }

                if (!string.IsNullOrEmpty(HttpContext.Session.GetString("CurrentUser")))
                {
                    var tokenId = await _shopping.AuthenticateUser(email.user_email);

                    VMUserDetail user_details = new VMUserDetail();
                    user_details.user_email       = email.user_email;
                    user_details.userAuthID       = tokenId;
                    user_details.IsToken          = true;
                    user_details.IsForgetPassword = email.IsForgetPassword;
                    user_details.cartId           = email.cartId;
                    ModelState.Clear();
                    return(this.View("GetUserDetails", user_details));
                }
                else
                {
                    return(View("error"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, new object[] { email });
                throw ex;
            }
        }
        public async Task AuthenticateUserEmail_Success()
        {
            //Arrange
            mockSession();
            _shopping.Setup(x => x.AuthenticateUser(It.IsAny <string>())).Returns(Task.FromResult(Guid.NewGuid()));
            VMUserDetail input = new VMUserDetail()
            {
                user_email       = "*****@*****.**",
                IsForgetPassword = 0,
                cartId           = 1
            };

            //Act
            var result = await controller.AuthenticateUserEmail(input) as ViewResult;

            //Assert
            Assert.Equal("GetUserDetails", result.ViewName);
        }
        public async Task <ActionResult> VerifyTokenAsync(VMUserDetail email)
        {
            _logger.LogInformation("VerifyTokenAsync started", new object[] { email });
            try
            {
                if (!string.IsNullOrEmpty(HttpContext.Session.GetString("CurrentUser")))
                {
                    bool verificationresult = await _shopping.VerifyUserToken(email.user_email, email.userAuthID, email.Token);

                    if (verificationresult)
                    {
                        if (email.IsForgetPassword > 0)
                        {
                            return(RedirectToAction("UpdateUserPasswordView", "User", new { userEmail = _encryption.EncryptText(email.user_email, ATMConstants.emailEncKey) }));
                        }
                        else
                        {
                            await _shopping.SendBookingConfirmation(email.user_email, email.cartId);

                            return(this.View(verificationresult));
                        }
                    }
                    else
                    {
                        VMUserDetail user_details = new VMUserDetail();
                        user_details.user_email = email.user_email;
                        user_details.IsToken    = true;
                        user_details.Message    = "Invalid token";

                        return(this.View("GetUserDetails", user_details));
                    }
                }
                else
                {
                    return(View("Error"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message, new object[] { email });
                throw ex;
            }
        }
        public async Task VerifyTokenAsync_tokenvalid_Success()
        {
            //Arrange
            mockSession();

            VMUserDetail input = new VMUserDetail()
            {
                user_email       = "*****@*****.**",
                IsForgetPassword = 0,
                cartId           = 1
            };

            _shopping.Setup(x => x.VerifyUserToken(It.IsAny <string>(), It.IsAny <Guid>(), It.IsAny <string>())).Returns(Task.FromResult(true));
            _shopping.Setup(x => x.SendBookingConfirmation(It.IsAny <string>(), It.IsAny <int>()));

            //Act
            var result = await controller.VerifyTokenAsync(input) as ViewResult;

            //Assert
            Assert.NotNull(result.Model);
        }
        // buy Now
        // Place order
        public ActionResult GetUserDetails(int isForgetPassword, int cartId = 0)
        {
            VMUserDetail user_details = new VMUserDetail();

            user_details.IsToken          = false;
            user_details.IsForgetPassword = isForgetPassword;
            user_details.cartId           = cartId;

            if (isForgetPassword == 1)
            {
                return(View(user_details));
            }
            else if (!string.IsNullOrEmpty(HttpContext.Session.GetString("CurrentUser")))
            {
                return(this.View(user_details));
            }
            else
            {
                return(View("Error"));
            }
        }
        public async Task <ActionResult> ResendAuthToken(VMUserDetail email)
        {
            if (!string.IsNullOrEmpty(HttpContext.Session.GetString("CurrentUser")))
            {
                var tokenId = await _shopping.AuthenticateUser(email.user_email);

                VMUserDetail user_details = new VMUserDetail();
                user_details.user_email       = email.user_email;
                user_details.userAuthID       = tokenId;
                user_details.IsToken          = true;
                user_details.Message          = string.Empty;
                user_details.IsForgetPassword = email.IsForgetPassword;
                user_details.cartId           = email.cartId;
                ModelState.Clear();
                return(this.View("GetUserDetails", user_details));
            }
            else
            {
                return(View("Error"));
            }
        }