Dear all,
I am writing to seek help in how do construct function/method which can pass username and password from database in the "userPro" class:
I manage to create method in data access layer:
Can I use login method in userPro class and if so, any guidelines or framework i could use to construct the above method/class.
Thank you for your time and help.
I am writing to seek help in how do construct function/method which can pass username and password from database in the "userPro" class:
publicclass UserPro : IProvidePrincipal
{
// private const string Username = "hi";
//private const string Password = "hi";
public IPrincipal CreatePrincipal(string username, string password)
{
if (username != Username || password != Password)
{
returnnull;
}
var identity = new GenericIdentity(Username);
IPrincipal principal = new GenericPrincipal(identity, new[] { "admin" });
return principal;
}
I manage to create method in data access layer:
publicclassUser : iUser
{
//private cdwEntities db = new cdwEntities();
private cdwEntities2 db;
public User(cdwEntities2 ctx)
{
db = ctx;
}
publicbool Login(string UserName, string Password)
{
var user = db.api_login.FirstOrDefault(u => u.username == UserName
&& u.password == Password);
if (user != null)
{
if (user.password == Password)
{
returntrue;
}
}
returnfalse;
}
}
Can I use login method in userPro class and if so, any guidelines or framework i could use to construct the above method/class.
Thank you for your time and help.