Example #1
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (model == null || model.Id == 0)
            {
                txtCodigo.Visibility = Visibility.Collapsed;
                lblCodigo.Visibility = Visibility.Collapsed;
                var json    = MyLocalStorage.GetFromLocalStorage("usuario");
                var usuario = JsonConvert.DeserializeObject <Usuario>(json.ToString());
                txtUsername.Text = usuario.Login;
            }
            else
            {
                txtCodigo.Text = model.Id.ToString();

                txtTitulo.Text = model.Titulo;

                dtpDataLimite.Date = model.DataLimite;

                txtDescricao.Text = model.Descricao;

                txtUsername.Text = model.Username;

                ckbConcluido.IsChecked = model.Concluido;
            }
        }
Example #2
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var usuario = (string)MyLocalStorage.GetFromLocalStorage("usuario");

            if (!string.IsNullOrWhiteSpace(usuario))
            {
                Frame.Navigate(typeof(HomePage));
            }
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var usuarioSalvo = (string)MyLocalStorage.GetFromLocalStorage(@"usuario");

            if (string.IsNullOrWhiteSpace(usuarioSalvo))
            {
                Frame.Navigate(typeof(MainPage));
            }
            else
            {
                usuario = JsonConvert.DeserializeObject <Usuario>(usuarioSalvo);

                txbTitulo.Text = $@"Olá {usuario.Login.Split('@')[0]}!";

                frmConteudo.Navigate(typeof(TarefasPage));
            }
        }
Example #4
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                var token = MyLocalStorage.GetFromLocalStorage("token");

                lista = await TarefasRequestApi.ListarTarefas(token.ToString());

                lstDados.ItemsSource = lista;
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(TratarException.ErrorMessage(ex));

                await dialog.ShowAsync();
            }
        }
Example #5
0
        private async void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtLogin.Text) || string.IsNullOrWhiteSpace(txtPassword.Password))
            {
                var dialog = new MessageDialog(@"O Login e a Senha são obrigatórios!", "Atenção!!");
                await dialog.ShowAsync();
            }
            else
            {
                var usuario = new Usuario
                {
                    Login = txtLogin.Text,
                    Senha = txtPassword.Password
                };

                try
                {
                    var token = await LoginRequestApi.Login(txtLogin.Text, txtPassword.Password);

                    if (!string.IsNullOrWhiteSpace(token))
                    {
                        var json = JsonConvert.SerializeObject(usuario);

                        MyLocalStorage.SaveToLocalStorage(@"usuario", json);

                        MyLocalStorage.SaveToLocalStorage("token", token);

                        Frame.Navigate(typeof(HomePage));
                    }
                    else
                    {
                        var dialog = new MessageDialog(@"Não foi possível fazer o login... Tente novamente", "Atenção!!");
                        await dialog.ShowAsync();
                    }
                }
                catch (Exception ex)
                {
                    var dialog = new MessageDialog(TratarException.ErrorMessage(ex), "Atenção!!");
                    await dialog.ShowAsync();
                }
            }
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (tarefa == null || tarefa.Id == 0)
            {
                txtCodigo.Visibility = Visibility.Collapsed;
                lblCodigo.Visibility = Visibility.Collapsed;
                var json  = MyLocalStorage.GetFromLocalStorage("usuario");
                var dados = JsonConvert.DeserializeObject <Usuario>(json.ToString());

                txtUsuario.Text = dados.Login;
            }
            else
            {
                txtCodigo.Text         = tarefa.Id.ToString();
                txtUsuario.Text        = tarefa.Username;
                txtDescricao.Text      = tarefa.Descricao;
                txtTitulo.Text         = tarefa.Titulo;
                dptDataLimite.Date     = tarefa.DataLimite;
                chkConcluido.IsChecked = tarefa.Concluido;
            }
        }
        private void lstMenuItems_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbiLogOff.IsSelected)
            {
                MyLocalStorage.RemoveFromLocalStorage(@"usuario");
                Frame.Navigate(typeof(MainPage));
            }
            else if (!lbiLogOff.IsSelected && !lbiHome.IsSelected)
            {
                btnBack.Visibility = Visibility.Visible;

                if (lbiTarefas.IsSelected)
                {
                    frmConteudo.Navigate(typeof(NovaTarefaPage));
                }
            }
            else
            {
                btnBack.Visibility = Visibility.Collapsed;
                frmConteudo.Navigate(typeof(TarefasPage));
            }
        }
Example #8
0
        private async void btnCadastrar_Click(object sender, RoutedEventArgs e)
        {
            var tudoPreenchido =
                !(
                    string.IsNullOrWhiteSpace(txtEmail.Text) ||
                    string.IsNullOrWhiteSpace(txtPassword.Password) ||
                    string.IsNullOrWhiteSpace(txtConfirmacao.Password)
                    );

            if (!tudoPreenchido)
            {
                var dialog = new MessageDialog(
                    "Todos os campos são obrigatórios!",
                    "Atenção!!!"
                    );
                await dialog.ShowAsync();
            }
            else
            {
                if (!ValidarEmail(txtEmail.Text))
                {
                    var dialog = new MessageDialog(
                        "Email inválido!",
                        "Atenção!!!"
                        );
                    await dialog.ShowAsync();
                }
                else
                {
                    if (txtPassword.Password.Length < 6)
                    {
                        var dialog = new MessageDialog(
                            "A senha tem que ter no mínimo 6 caracteres!",
                            "Atenção!!!"
                            );
                        await dialog.ShowAsync();
                    }
                    else
                    {
                        if (txtPassword.Password != txtConfirmacao.Password)
                        {
                            var dialog = new MessageDialog(
                                "Senha e Confirmação devem ser iguais!",
                                "Atenção!!!"
                                );
                            await dialog.ShowAsync();
                        }
                        else
                        {
                            try
                            {
                                var coisa = await NovoUsuarioRequestApi.Cadastrar(
                                    txtEmail.Text,
                                    txtPassword.Password,
                                    txtConfirmacao.Password
                                    );

                                if (coisa)
                                {
                                    var token = await LoginRequestApi.Login(
                                        txtEmail.Text,
                                        txtPassword.Password
                                        );

                                    var usuario = new Usuario
                                    {
                                        Login = txtEmail.Text,
                                        Senha = txtPassword.Password
                                    };

                                    var json = JsonConvert.SerializeObject(usuario);

                                    MyLocalStorage.SaveToLocalStorage("usuario", json);

                                    MyLocalStorage.SaveToLocalStorage("token", token);

                                    Frame.Navigate(typeof(HomePage));
                                }
                            }
                            catch (Exception ex)
                            {
                                var dialog = new MessageDialog(
                                    TratarException.ErrorMessage(ex),
                                    "Atenção!!!"
                                    );
                                await dialog.ShowAsync();
                            }
                        }
                    }
                }
            }
        }