登录时检查三个条件 [英] Check three condition on login

查看:68
本文介绍了登录时检查三个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi, am new to mvc web api actually am trying to login with three condition 
 
 
 
problem (1) 
   if ( 1. login if email exist in emp table (or)2. login if email exist in user table )
   {
      
      return "succeslogin"; 
   }
   else if( 3. login if email exist in emp table for first time )
      { 
       
       return "succeslogin_first_time";
       } 
 }
else
{
 return "fails"; 
} 
 
 In my C#
 
public class All
{
public string EmailId { get; set; }
public string Password { get; set; }
}
 
public partial class tblEmployee
{
public int Id { get; set; }
public long Emp_Id { get; set; }
public string Emp_Email { get; set; }
public string Emp_Name { get; set; }
public string Emp_Dept { get; set; }
public Nullable<long> Emp_Mobile { get; set; }
public Nullable<long> Emp_Payroll { get; set; }
public string Emp_Password { get; set; }
public Nullable<bool> Emp_FirstLog { get; set; }
}
public partial class tblUser
{
public int Id { get; set; }
public string Email { get; set; }
public string Password { get; set; }
}
 
 
public string LoginAttempt(All user)
{
var loginEmp = db.tblEmployees.FirstOrDefault(e => e.Emp_Email == user.EmailId);
var loginUser = db.tblUsers.FirstOrDefault(u => u.Email == user.EmailId);
if (loginEmp != null || loginUser != null)
{
return "loginsuccess";
}
else if (loginEmp.Emp_FirstLog == "true") // 
{
return "error";
}
else{
return "error";
}
}
 
 
 Error 1 Inconsistent accessibility: parameter type 'ServerControl.Controllers.All' is less accessible than method 'ServerControl.Controllers.LoginAcuteController.LoginAttempt(ServerControl.Controllers.All)'
 Error 2 Operator '==' cannot be applied to operands of type 'bool?' and 'string'
 
  
 Problem(2)
 
1.How can i check if email login  for first time 
2.How can i define in email login for first time in database
 
 
 
please help me to solve this issue  





我尝试过:



试图这样做但是我得到了

错误1可访问性不一致:参数类型'ServerControl.Controllers.All'比方法'ServerControl.Controllers.LoginAcuteController.LoginAttempt(ServerControl.Controllers.All)更难访问)'

错误2运算符'=='不能应用于'bool?'类型的操作数和'string'



What I have tried:

tried to do but i got
Error 1 Inconsistent accessibility: parameter type 'ServerControl.Controllers.All' is less accessible than method 'ServerControl.Controllers.LoginAcuteController.LoginAttempt(ServerControl.Controllers.All)'
Error 2 Operator '==' cannot be applied to operands of type 'bool?' and 'string'

推荐答案

第二个问题很明显:

The second problem is obvious:
Operator '==' cannot be applied to operands of type 'bool?' and 'string'




else if (loginEmp.Emp_FirstLog == "true")



Emp_FirstLog被声明为Nullable< bool> ;,而不是字符串。

所以试试:


Emp_FirstLog is declared as Nullable<bool>, not string.
So try:

else if (loginEmp.Emp_FirstLog == true)

而且这个错误应该消失。



第一个是比较棘手的:从你的代码来看,从术语中发生的事情来看并不明显声明。

但基本上,All类(或可能是LoginAcuteController类,但可能不太可能)的包含类中的某些内容是 protected internal private ,这与LoginAttempt方法的公共声明不兼容 - 这意味着一些人可以调用该方法的de无法访问它需要传递给它的类。因此错误信息。

我建议你仔细查看所有容器类,并准确评估你正在使用的访问修饰符以及你需要的访问修饰符:谁真的需要访问该方法? br />
对不起 - 但我们不能为你做到这一点!

And that error should go away.

The first one is trickier: it's not obvious from your code exactly what is going on in terms of the declarations.
But basically, something in the containing classes for the All class (or possibly the LoginAcuteController class, but that's less likely) is protected, internal, or private, and that isn't compatible with the public declaration of the LoginAttempt method - which means that some code which can call the method can't access the class it needs to pass to it. Hence the error message.
I'd suggest a good close look at all your container classes and evaluate exactly what access modifier you are using and which you need: who does really need access to the method?
Sorry - but we can't do that for you!


这篇关于登录时检查三个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆