public async Task<IActionResult> LoginPartial(LoginViewModel model, string returnUrl = null)
        {
            EnsureDatabaseCreated(_applicationDbContext);
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                // This doesn't count login failures towards account lockout
                // To enable password failures to trigger account lockout, set lockoutOnFailure: true
                var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
                if (result.Succeeded)
                {
                    // Add Current AppUserID and other Required User Info to Session
                    var appUserInfo = await _userManager.FindByNameAsync(User.Identity.Name);
                    if (appUserInfo == null) throw new Exception($"Could not locate the user {User.Identity.Name} in store");

                    AppSession.AppUserId = appUserInfo.AppUserId;
                    AppSession.FullName = appUserInfo.FullName;
                    AppSession.Email = appUserInfo.Email;
                    AppSession.PhoneNumber = appUserInfo.PhoneNumber;

                    var data = new { success = AppSession.AppUserId != null, name = AppSession.FullName, email = AppSession.Email };
                    return Json(data);
                }
                if (result.RequiresTwoFactor)
                {
                    //ToDo: Make this work in Partial View
                    return RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                }
                if (result.IsLockedOut)
                {
                    //ToDo: Make this work in Partial View
                    return PartialView("Lockout");
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                    return PartialView(model);
                }
            }

            // If we got this far, something failed, redisplay form
            return PartialView(model);
        }
        public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            EnsureDatabaseCreated(_applicationDbContext);
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                // This doesn't count login failures towards account lockout
                // To enable password failures to trigger account lockout, set lockoutOnFailure: true
                var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
                if (result.Succeeded)
                {

                    return RedirectToLocal(returnUrl);
                }
                if (result.RequiresTwoFactor)
                {
                    return RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
                }
                if (result.IsLockedOut)
                {
                    return View("Lockout");
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                    return View(model);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }