Return 来自任务的布尔值,用于检查 Firebase 实时数据库中是否存在字符串
Return Boolean from Task, That checks if string exist in Firebase Realtime Database
任务将两个字符串从 getuser() 传递到 DBFirebase class。然后它使用这些字符串来检查它们是否存在于 Firebase 实时数据库中。我怎样才能 return “CheckLogin”到登录页面?。我尝试将任务更改为任务,但它会阻止将字符串发送到数据库。有什么建议吗?
//LoginPage.xaml.cs
public async void getuser()
{
await services.LoginCheck(EmailEntry.Text, PasswordEntry.Text);
}
//DBFirebase.cs
public async Task LoginCheck(string email, string password)
{
var LoginCheck = (await Client.Child("users").OnceAsync<users>()).FirstOrDefault(a => a.Object.email == email && a.Object.password == password);
if (LoginCheck == null)
{
CheckLogin = false;
}
else
{
CheckLogin = true;
}
public async Task<bool> LoginCheck(string email, string password)
{
bool CheckLogin = false;
var LoginCheck = (await Client.Child("users").OnceAsync<users>()).FirstOrDefault(a => a.Object.email == email && a.Object.password == password);
if (LoginCheck == null)
{
CheckLogin = false;
}
else
{
CheckLogin = true;
}
return CheckLogin;
}
调用它
var check = await services.LoginCheck(EmailEntry.Text, PasswordEntry.Text);
任务将两个字符串从 getuser() 传递到 DBFirebase class。然后它使用这些字符串来检查它们是否存在于 Firebase 实时数据库中。我怎样才能 return “CheckLogin”到登录页面?。我尝试将任务更改为任务,但它会阻止将字符串发送到数据库。有什么建议吗?
//LoginPage.xaml.cs
public async void getuser()
{
await services.LoginCheck(EmailEntry.Text, PasswordEntry.Text);
}
//DBFirebase.cs
public async Task LoginCheck(string email, string password)
{
var LoginCheck = (await Client.Child("users").OnceAsync<users>()).FirstOrDefault(a => a.Object.email == email && a.Object.password == password);
if (LoginCheck == null)
{
CheckLogin = false;
}
else
{
CheckLogin = true;
}
public async Task<bool> LoginCheck(string email, string password)
{
bool CheckLogin = false;
var LoginCheck = (await Client.Child("users").OnceAsync<users>()).FirstOrDefault(a => a.Object.email == email && a.Object.password == password);
if (LoginCheck == null)
{
CheckLogin = false;
}
else
{
CheckLogin = true;
}
return CheckLogin;
}
调用它
var check = await services.LoginCheck(EmailEntry.Text, PasswordEntry.Text);