检查成员列表以查找是否匹配给定属性(例如密码)
我的问题在于下面的这一点。 它的功能是NULL或Whitespace问题的预期,但是将我的员工登录详细信息移植到SQLite DB之后,我现在正在努力正确测试输入是否与所有其他已知成员通行证不匹配[Passcodes]。 对于代码表中的每个工作人员的密码vars来说,这很简单,其中包含名称等,但是rudimemtary和我已经写了一种将新员工添加到此DB的方式,很高兴知道如何正确限定资格它们不存在/与输入对象entpassword.text中找到的输入,并存储在“代码背后的代码”中的变量通道中。
任何方向都会很棒,因为我觉得我缺少或以前错过了一些明显的解决方案。 以下是代码段,其中代码可以有效地通过已实现的检查检查,因此很难遵循断点,因为它只能等待更多输入[如果是正确的密码,则它将记录在中绝对很好]。 也许整个方法是错误的,我不知道:/ 这是 youtube屏幕录制问题如果您想要额外的清晰度 - 编辑:如果您观看视频,请静音,它的通知铃声响起,这些铃声的记录不好:)
代码片段下面:
private async void BtnLogin_Clicked(object sender, EventArgs e)
{
string pass = entPassword.Text;
if (string.IsNullOrWhiteSpace(pass))
{
InputError($"Passcode: ?{pass} ? Shows nothing was entered: Entry DENIED!");
}
else
{
List<Member> members = await App.Db.GetMembersAsync();
IEnumerable<string> memberPasses = from m in members where m.Pass == pass select m.Pass;
//the trouble ahead...
foreach (string p in memberPasses)
{
if (pass != p)
{
InputError($"Passcode: {pass} was NOT a recognized code");
}
else
{
IEnumerable<Member> member = from m in members
where m.Pass == p
select m;
Member mem = (Member)member.FirstOrDefault();
mem.DateStamp = DateTime.Now.ToShortDateString();
mem.TimeStamp = DateTime.Now.ToShortTimeString();
memberDetails = new string($" {mem.Usr} @ {mem.TimeStamp} on {mem.DateStamp}");
await App.Db.UpdateMemberAsync(mem);
NextPage();
}
}
}
}
My issue lies in this bit of code below.
It functions as expected for null or whitespace issue but after porting my staff member login details over to an SQLite db, I'm now struggling to correctly test if the input is a mismatch to all other known member passes[passcodes].
This was obvs much simpler with passcode vars for each staff member in the code sheet with names in there etc, but rudimemtary and I've written in a way to add new staff to this db and it would be good to know how to correctly qualify they dont exist/ match with the input found in the Entry object entPassword.Text and stored in the variable pass in the "code behind".
Any direction would be great as I feel like I'm missing or have previously miss coded some obvious solution.
below is the code snippet where the code just effectively falls through the implemented foreach
check, making it tough to follow the breakpoint as it just waits ready for more input [which if is the correct passcode, it logs in absolutely fine ].
Maybe the entire approach is wrong, I dunno:/
here is a youtube screen recording of it too, so you can see the non-functioning issue if you wanted for extra clarity - EDIT: please MUTE the video if you watch it, its got horrible notification bell noises that are recorded badly :)
Code snippet below:
private async void BtnLogin_Clicked(object sender, EventArgs e)
{
string pass = entPassword.Text;
if (string.IsNullOrWhiteSpace(pass))
{
InputError(quot;Passcode: ?{pass} ? Shows nothing was entered: Entry DENIED!");
}
else
{
List<Member> members = await App.Db.GetMembersAsync();
IEnumerable<string> memberPasses = from m in members where m.Pass == pass select m.Pass;
//the trouble ahead...
foreach (string p in memberPasses)
{
if (pass != p)
{
InputError(quot;Passcode: {pass} was NOT a recognized code");
}
else
{
IEnumerable<Member> member = from m in members
where m.Pass == p
select m;
Member mem = (Member)member.FirstOrDefault();
mem.DateStamp = DateTime.Now.ToShortDateString();
mem.TimeStamp = DateTime.Now.ToShortTimeString();
memberDetails = new string(quot; {mem.Usr} @ {mem.TimeStamp} on {mem.DateStamp}");
await App.Db.UpdateMemberAsync(mem);
NextPage();
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
搜索成员列表以找出是否与给定属性匹配。
在这里,“通过”与“成员”相比:
To search a list of members to find out if any match a given property.
Here, "pass" compared to "member.Pass":