public async Task <IHttpActionResult> ForgotPassword(ForgotPasswordBindingModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);

                // If user has to activate his email to confirm his account, the use code listing below
                //if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                //{
                //    return Ok();
                //}
                if (user == null)
                {
                    return(Ok());
                }
                var modelPassword = new SetPasswordBindingModel();
                modelPassword.NewPassword     = PasswordGeneratorService.GeneratePassword(6);
                modelPassword.ConfirmPassword = modelPassword.NewPassword;
                modelPassword.Code            = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                var result = SetPassword(user, modelPassword);
                await UserManager.SendEmailAsync(user.Id, "Сброс пароля", $"Ваш новый пароль::" + modelPassword.NewPassword);

                return(Ok());
            }

            // If we got this far, something failed, redisplay form
            return(BadRequest(ModelState));
        }
        private void CreateNewUser(object obj)
        {
            String password = null;

            if (_name != null && _login != null && _email != null)
            {
                password = _pwGenerator.GeneratePassword();
                _dataService.EditUser(password, _name, _login, _email, _userRole, _user.Id);
                _mailService.SendEmailAsync(_email, _login, password);
                Messenger.Default.Send <User>(_loggedInUser);
                _navigationService.NavigateTo("Staff");
            }
        }