コード例 #1
0
ファイル: Cadastro.xaml.cs プロジェクト: nevesvox/SlimApp
        private async void Button_Confirmar(object sender, EventArgs e)
        {
            if (VerificaCamposCadastro())
            {
                // Chama o Popup de Loading
                await PopupNavigation.Instance.PushAsync(new LoadingPopUpView());

                // Envia a requisição de cadastro para a API
                var result = clienteService.CadastraCliente(
                    entryNome.Text,
                    entryCPF.Text,
                    entryTelefone.Text,
                    entryEmail.Text,
                    entrySenha.Text
                    );

                // Verifica o resultado da requisição
                if (result.Tipo == "ok")
                {
                    // Fecha o Popup de Loading
                    await PopupNavigation.Instance.PopAsync();

                    // Exibe o alerta
                    await DisplayAlert("Tudo Certo!", "Seu cadastro foi realizado com sucesso, agora você pode realizar o login e realizar suas compras!", "Aceitar");

                    await Navigation.PopAsync();

                    return;
                }
                else if (result.Tipo == "notOk")
                {
                    // Fecha o Popup de Loading
                    await PopupNavigation.Instance.PopAsync();

                    // Exibe o alerta
                    await DisplayAlert("Ops...", "Email já cadastrado no sistema!", "Aceitar");

                    // Foca o email
                    entryEmail.Focus();
                    return;
                }
            }
        }
コード例 #2
0
        async Task <bool> CadastraCliente(ClienteModel cliente)
        {
            IsBusy = true;
            ClienteService clienteCad = new ClienteService();

            cliente = await clienteCad.CadastraCliente(cliente);

            IsBusy = false;

            if (cliente == null || cliente.IdCliente == 0)
            {
                await DisplayAlert("Alerta!", "Falha ao cadastrar cliente.", "OK");

                //btnCancelaCliente.IsEnabled = false;
                return(false);
            }
            else
            {
                GlobalVariables.GlobalClientePedido = cliente;
                //btnCancelaCliente.IsEnabled = true;
                return(true);
            }
        }