예제 #1
0
        private async void btnLogin_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(email.Text) || String.IsNullOrEmpty(password.Text))
            {
                await DisplayAlert(ResxFile.btnLogin, ResxFile.msg_LoginEmpty, ResxFile.btn_ok);
            }
            else
            {
                BaseModel result = await APIConnection.Login(email.Text, password.Text);

                if (result.Errors != null)
                {
                    await DisplayAlert(ResxFile.btnLogin, ResxFile.msg_Login_Fail, ResxFile.btn_ok);

                    return;
                }
                try
                {
                    await SecureStorage.SetAsync("UserId", result.Data.Login.UserId);

                    await SecureStorage.SetAsync("Token", result.Data.Login.Token);

                    await SecureStorage.SetAsync("UserName", result.Data.Login.UserName);
                } catch (Exception)
                {
                    await DisplayAlert(ResxFile.btnLogin, ResxFile.msg_Login_Fail, ResxFile.btn_ok);

                    return;
                }
                //AuthData authData = result.Data.Login;
                await Navigation.PopAsync();
            }
        }