Exemple #1
0
        private async void LoginBtn_Click(object sender, EventArgs e)
        {
            loginBtn.Enabled = registerBtn.Enabled = false;

            var areValidInputs = LoginViewModel.CheckInputs(usernameTxt.Text, passwordTxt.Text);

            ShowErrors(areValidInputs);

            if (areValidInputs != Validation.Correct)
            {
                loginBtn.Enabled = registerBtn.Enabled = true;
                return;
            }

            var userFound = await Services.PicSayAndPlayService.LoginUser(usernameTxt.Text, passwordTxt.Text);

            if (userFound == null)
            {
                Snackbar.Make(sender as Android.Views.View, "Datos incorrectos :(", Snackbar.LengthLong).Show();
                loginBtn.Enabled = registerBtn.Enabled = true;
                CleanInputs();
                loginBtn.RequestFocus();
                return;
            }

            loginBtn.Enabled = registerBtn.Enabled = true;

            var session = new UserSessionManager(this);

            session.CreateUserLoginSession(userFound.NickName, passwordTxt.Text);
            Intent i = new Intent(this, typeof(MainActivity));

            StartActivity(i);
            this.Finish();
        }