Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
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  


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'
Posted
Updated 24-Jun-16 21:46pm

1 solution

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

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

Emp_FirstLog is declared as Nullable<bool>, not string.
So try:
C#
else if (loginEmp.Emp_FirstLog == true)
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!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900