Beispiel #1
0
 public override void AddUsersToRoles(string[] usernames, string[] roleNames)
 {
     foreach (var username in usernames)
     {
         foreach (var role in roleNames)
         {
             if (!IsUserInRole(username, role))
             {
                 try
                 {
                     RoleUser link = new RoleUser();
                     link.Role = db.Roles.SingleOrDefault(r => r.Name == role);
                     link.User = db.Users.SingleOrDefault(u => u.Username == username);
                     db.RoleUsers.InsertOnSubmit(link);
                     db.SubmitChanges();
                 }
                 catch
                 {
                 }
             }
         }
     }
 }
 partial void DeleteRoleUser(RoleUser instance);
 partial void UpdateRoleUser(RoleUser instance);
 partial void InsertRoleUser(RoleUser instance);
		private void detach_RoleUsers(RoleUser entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
		private void attach_RoleUsers(RoleUser entity)
		{
			this.SendPropertyChanging();
			entity.User = this;
		}