コード例 #1
0
        public async void Salvar()
        {
            try
            {
                if (await controller.AlterarSenha(txtSenhaAtual.Text, txtNovaSenha.Text))
                {
                    await DisplayAlert(string.Empty, "Senha alterada com sucesso", "Ok");

                    await Navigation.PopAsync();
                }
                else
                {
                    throw new ApplicationException("Não foi possível alterar a senha.\nPor favor, tente novamente mais tarde.");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Atenção", ex.Message, "Ok");
            }
        }
コード例 #2
0
    protected void Btalterar_Click(object sender, EventArgs e)
    {
        //Colocando os valores no bean


        //usuario.Senha = TxtSenha.Text;

        //Mandando para o controler
        usucont = new UsuarioController();
        try
        {
            usuario                = new UsuarioBean();
            usuario.Id             = int.Parse(Session["usuarioId"].ToString());
            usuario.Senha          = TxtSenha.Text;
            usuario.Confirmarsenha = TxtConfirmarSenhaNova.Text;
            usucont.ConfirmarSenha(usuario);
            try {
                usuario.Senha = TxtSenhaNova.Text;
                usucont.AlterarSenha(usuario);
                Response.Redirect("Perfil.aspx");
            }
            catch (SenhaUsuarioInvalidaException) {
                Labelerro.Text = "Campos de senha nova não conferem";
            }
        }
        catch (UsuarioInvalidoException)

        {
            Labelerro.Text = "Campo senha atual incorreto";
            //Redirecionar para pagina de logado
            //FormsAuthentication.RedirectFromLoginPage(usuario.Email, false);//mudar para true para manter o usuario logado
        }
        catch (Exception)
        {
            Labelerro.Text = "Erro inesperado do sistema, contate um administrador";
        }
    }