public IActionResult Register(string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;

            if (AjaxExtensions.IsAjaxRequest(Request))
            {
                return(PartialView());
            }

            return(View());
        }
        public async Task <IActionResult> Login(LoginViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            var isAjax = AjaxExtensions.IsAjaxRequest(Request);

            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)
                {
                    _logger.LogInformation(1, "User logged in.");
                    return(RedirectToLocal(returnUrl));
                }
                if (result.RequiresTwoFactor)
                {
                    return(RedirectToAction(nameof(SendCode), new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }));
                }
                if (result.IsLockedOut)
                {
                    _logger.LogWarning(2, "User account locked out.");

                    if (isAjax)
                    {
                        return(PartialView("Lockout"));
                    }

                    return(View("Lockout"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid login attempt.");

                    if (isAjax)
                    {
                        return(PartialView(model));
                    }

                    return(View(model));
                }
            }

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