public Lembretes(string login) { user = login; ds = new LembreteDataService(); controller = new LembreteController(); CarregaLembretes(); }
private async void BtnFinalizarCadastro_ClickedAsync(object sender, EventArgs e) { try { List <Models.Cadastro> cadastros = await ds.GetCadastroAsync(); //Lista com todos os cadastros try { string result; //Mensagem a ser exibida //Recebe informações Models.Cadastro cadastro = new Models.Cadastro { login = txtCadLogin.Text.Trim(), senha = txtCadSenha.Text.Trim(), nome = txtCadNome.Text.Trim(), email = txtCadEmail.Text.Trim(), cpf = txtCadCpf.Text.Trim() }; string confsenha = txtConfSenha.Text.Trim(); result = controller.Cadastro(cadastro, confsenha, cadastros); var msg = System.Text.RegularExpressions.Regex.Split(result, ";"); //Faz a separação da mensagem em 3 strings await DisplayAlert(msg[0], msg[1], msg[2]); if (msg[0].Equals("Sucesso")) { await ds.AddCadastroAsync(cadastro); //Adiciona os lembretes padrão ao criar um novo perfil LembreteController lc = new LembreteController(); lc.CriarLembretes(cadastro); Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 1]); } } catch (Exception ex) { await DisplayAlert("Erro:", "Preencha todos os campos", "OK"); } } catch (Exception ex) { await DisplayAlert("Erro:", "Sem conexão com a internet", "OK"); } }
private async void BtnLogin_ClickedAsync(object sender, EventArgs e) { try { List <Models.Cadastro> cadastros = await ds.GetCadastroAsync(); //Lista com todos os cadastros try { string result; //Mensagem a ser exibida //Recebe os dados string login = txtUsuario.Text.Trim(); string senha = txtSenha.Text.Trim(); result = controller.Login(login, senha, cadastros); var msg = System.Text.RegularExpressions.Regex.Split(result, ";"); //Faz a separação da mensagem em 3 strings if (!msg[0].Equals("Erro")) { LembreteDataService ds = new LembreteDataService(); //Carrega todos os lembretes List <Models.Lembrete> lembretes = await ds.GetLembreteAsync(); LembreteController lc = new LembreteController(); //Retorna um lembrete aleatório, se houver string lembrete = lc.GetLembrete(login, lembretes); await Navigation.PushAsync(new Inicial(login)); Limpar(); await DisplayAlert(msg[0], lembrete, msg[2]); //Exibe um lembrete aleatório ao usuário, além da mensagem padrão } else { await DisplayAlert(msg[0], msg[1], msg[2]); } } catch (Exception ex) { await DisplayAlert("Erro:", "Preencha todos os campos", "OK"); } } catch (Exception ex) { await DisplayAlert("Erro:", "Sem conexão com a internet", "OK"); } }