public InsertCodeViewModel()
        {
            API = new ClienteAPIService();
            LabelVisible = false;
            
            MessagingCenter.Subscribe<InsertCodePage>(this, "InsertCodeRegisterClicked", async (page) =>
            {
                var success = await API.ValidateAccount(ValidarConta);

                if (success)
                {
                    App.Current.MainPage = new LoginPage();
                }
                else
                {
                    LabelVisible = true;
                }
            });
        }
Exemple #2
0
        public EditarContaViewModel()
        {
            API = new ClienteAPIService();

            Cliente = new Cliente();
            //Console.WriteLine("Yeeet: " + Cliente.Email);

            /*
             * MessagingCenter.Subscribe<EditarContaPage>(this, "InsertCodeRegisterClicked", async (page) =>
             * {
             *  var success = await API.ValidateAccount(ValidarConta);
             *
             *  if (success)
             *  {
             *      App.Current.MainPage = new LoginPage();
             *  }
             *  else
             *  {
             *      LabelVisible = true;
             *  }
             * });*/
        }
        public SignUpViewModel()
        {
            API   = new ClienteAPIService();
            Conta = new CriarContaPostModel();
            Erros = new List <string>();

            MessagingCenter.Subscribe <SignUpPage>(this, "SignUpRegisterClicked", async(page) =>
            {
                var erros = await API.CriarConta(Conta);
                List <string> errosStr = new List <string>();

                if (!erros.Erros.Any())
                {
                    var viewModel          = new InsertCodeViewModel();
                    viewModel.ValidarConta = new ValidarContaPostModel {
                        Email = Conta.Email
                    };
                    var validarConta = new ValidarContaPostModel {
                        Email = Conta.Email
                    };
                    await page.Navigation.PushModalAsync(new InsertCodePage(new InsertCodeViewModel {
                        ValidarConta = validarConta
                    }));
                }

                else
                {
                    foreach (int erro in erros.Erros)
                    {
                        errosStr.Add(ErrorMessages._messages[erro]);
                    }
                }
                Erros = errosStr;
                //page.ErrorsList.ItemsSource = Erros;
            });
        }
        public LoginViewModel()
        {
            API          = new ClienteAPIService();
            Login        = new LoginPostModel();
            LabelVisible = false;

            MessagingCenter.Subscribe <LoginPage>(this, "LoginClicked", async(page) =>
            {
                var success = await API.AuthenticateClient(Login);

                // Login falhou
                if (!success)
                {
                    LabelVisible = true;
                }
                // Login bem sucedido
                else
                {
                    LabelVisible         = false;
                    MainPage homePage    = new MainPage();
                    App.Current.MainPage = homePage;
                }
            });
        }