public async Task <IActionResult> Login([FromBody] LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                UserInformation userInformation = new UserInformation();

                try
                {
                    //var result = await _signInMgr.PasswordSignInAsync(model.UserName, model.Password, false, false);
                    //var result = await signInManager.PasswordSignInAsync(model.Email, model.Password, true, false);

                    var result = await signInManager.PasswordSignInAsync(
                        model.UserName, model.Password, true, false);

                    //var user = await userManager.FindByNameAsync(.FindByLoginAsync(.FindAsync(context.UserName, context.Password);

                    if (result.Succeeded)
                    {
                        FairfieldAllergeryRepository fairfieldAllergeryRepository = new FairfieldAllergeryRepository();

                        if (fairfieldAllergeryRepository.HasUserChangedIdAndPassword(model.UserName))
                        {
                            userInformation          = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                            userInformation.Password = model.Password;
                            userInformation.Status   = "Success";
                            return(Ok(userInformation));
                            //return Ok(new { status = "Success" });
                        }
                        else
                        {
                            userInformation          = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                            userInformation.Password = model.Password;
                            userInformation.Status   = "Change";
                            return(Ok(userInformation));
                        }
                    }
                }
                catch (Exception ex)
                {
                    string s1 = ex.ToString();
                }
            }

            return(Ok(new { status = "Failure" }));
        }
        public async Task <IActionResult> ChangeCredentials([FromBody] ChangeCredentialsViewModel model)
        {
            ChangeCredentials changeCredentials = new ChangeCredentials();

            if (ModelState.IsValid)
            {
                UserInformation userInformation = new UserInformation();
                FairfieldAllergeryRepository fairfieldAllergeryRepository = new FairfieldAllergeryRepository();

                try
                {
                    var result = await signInManager.PasswordSignInAsync(
                        model.OldUserName, model.OldPassword, true, false);

                    //If signin works
                    if (result.Succeeded)
                    {
                        //Check to see if user llready exists
                        if (fairfieldAllergeryRepository.CheckToSeeIfIdIsAlreadyUsed(model.UserName))
                        {
                            var user = await userManager.FindByNameAsync(model.OldUserName);

                            var checkPassword = await signInManager.CheckPasswordSignInAsync(user, model.OldPassword, true);

                            if (checkPassword.Succeeded)
                            {
                                var token = await userManager.GeneratePasswordResetTokenAsync(user);

                                if (user != null)
                                {
                                    var passwordChangeResult = await userManager.ResetPasswordAsync(user, token, model.Password);

                                    if (passwordChangeResult.Succeeded)
                                    {
                                        //if (await userManager.IsLockedOutAsync(user))
                                        //{
                                        //    await userManager.SetLockoutEndDateAsync(user, DateTimeOffset.UtcNow);
                                        //}
                                        fairfieldAllergeryRepository.UpdateUseridAndPassword(model);
                                    }
                                    else
                                    {
                                        userInformation              = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                                        userInformation.Status       = "Failure";
                                        userInformation.ErrorMessage = "Password change did not succeed";
                                        return(Ok(userInformation));
                                    }
                                }
                                else
                                {
                                    userInformation              = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                                    userInformation.Status       = "Failure";
                                    userInformation.ErrorMessage = "User is null";
                                    return(Ok(userInformation));
                                }
                            }
                            else
                            {
                                userInformation              = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                                userInformation.Status       = "Failure";
                                userInformation.ErrorMessage = "Password check failed";
                                return(Ok(userInformation));
                            }
                        }
                        else
                        {
                            userInformation              = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                            userInformation.Status       = "Failure";
                            userInformation.ErrorMessage = "UserId already taken.  Please select another";
                            return(Ok(userInformation));
                        }
                        //***************************************************************************************************
                        if (fairfieldAllergeryRepository.HasUserChangedIdAndPassword(model.UserName))
                        {
                            userInformation        = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                            userInformation.Status = "Success";
                            return(Ok(userInformation));
                        }
                        else
                        {
                            userInformation        = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                            userInformation.Status = "Change";
                            return(Ok(userInformation));
                        }
                    }
                    else
                    {
                        changeCredentials.Status       = "Failure";
                        changeCredentials.ErrorMessage = "None";
                        userInformation = fairfieldAllergeryRepository.GetUserInformation(model.UserName);
                        return(Ok(userInformation));

                        return(Ok(changeCredentials));
                    }
                }
                catch (Exception ex)
                {
                    string s1 = ex.ToString();
                }
            }

            changeCredentials.Status       = "Failure";
            changeCredentials.ErrorMessage = "None";

            return(Ok(changeCredentials));
        }