Hi ,
i have this Database table(UserID,Name,Surname,Username,Password,Email) and table(RoleID,RoleName,Description) and table(UserID,RoleID )so i create a Login Authentication with username and password to access to the application (with Linq ToSql to store data) and it is right .
Now i wish create a role for each user but i don't know how work out it ...i saw some features about it but refer to web.app ..
I post the code of the procedure that apply to login:enter code here
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
public bool ValidateApplicationUser(string userName, string password)
{
{
var AuthContext = new DataClasses1DataContext();
var query = from c in AuthContext.Users
where (c.Username == userName.ToLower() && c.Password == password.ToLower())
select c;
if(query.Count() != 0 )
{
return true;
}
return false;
}
}
private void mahhh(object sender, RoutedEventArgs e)
{
bool authenticated = true;
{
if (usernameTextBox.Text !="" && passwordTextBox.Text != "")
{
authenticated = ValidateApplicationUser(usernameTextBox.Text , passwordTextBox.Text);
}
}
if (!authenticated)
{
MessageBox.Show("Invalid login. Try again.");
}
else
{
MessageBox.Show("Congradulations! You're a valid user!");
Window3 c = new Window3();
c.ShowDialog();
this.Close();
}
}
}
Now i don't know how implement a method(code) to assign a role to the user :( .. Do you have any idea or suggest to make it right?
Thanks ...have a nice day.
Bye