/// <summary>
        /// PasswordSignInAsync
        /// </summary>
        /// <param name="user"></param>
        /// <param name="password"></param>
        /// <param name="isPersistent"></param>
        /// <param name="lockoutOnFailure"></param>
        /// <returns></returns>
        public override async Task <SignInResult> PasswordSignInAsync(PULUser user, string password, bool isPersistent, bool lockoutOnFailure)
        {
            // If needed, verify locked out attempts and return failure
            //var attempt = await CheckPasswordSignInAsync(user, password, lockoutOnFailure);
            var item    = user as User;
            var attempt = agent.GetUserByCredentials(item.Username.ToLower(), password, item.Token);

            attempt.objectResult.SecurityStamp = Guid.NewGuid();
            //user.Equals(attempt.objectResult.Id);

            return(attempt.Success
               ? await SignInOrTwoFactorAsync(user, isPersistent)
               : SignInResult.Failed);
        }
        public async Task <IActionResult> Login(User user)
        {
            if (ModelState.IsValid)
            {
                var resultToken = _accountAgent.GetToken(user);
                if (resultToken.Success)
                {
                    //HttpContext.Session.Set(Constants.SessionKeyState, token.objectResult);
                    //user.Token = token.objectResult;
                    var result = await _signInManager.PasswordSignInAsync(user.Username, user.Password, false, lockoutOnFailure : false);

                    if (result.Succeeded)
                    {
                        var userData      = _accountAgent.GetUserByCredentials(user.Username, user.Password, resultToken.objectResult).objectResult;
                        var userId        = userData.Id;
                        var establishment = _establishmentAgent.GetEstablishmentById(userId);

                        if (establishment.Success)
                        {
                            userData.Establishment = establishment.objectResult;
                            var menu = _accountAgent.GetModulesByUserId(userId, null);

                            if (menu.Success)
                            {
                                userData.Modules = menu.objectResult;
                            }
                        }
                        else
                        {
                            HttpContext.Session.Set(Constants.SessionKeyState, userData);
                            return(await Task.FromResult(RedirectToAction("NewEstablishment", "Establishment")));
                        }

                        //this.User.GetUserId();
                        HttpContext.Session.Set(Constants.SessionKeyState, userData);
                        return(await Task.FromResult(RedirectToAction("Dashboard", "Book")));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid credentials");
                    }
                }
            }
            return(await Task.FromResult(View(user)));
        }