Example #1
0
 /// <summary>
 /// Adds the specified users to the specified roles
 /// </summary>
 public override void AddUsersToRoles(string[] usernames, string[] roleNames)
 {
     // foreach user
     foreach (string uname in usernames)
     {
         int userID = (from u in db.Users where u.Username == uname select u.UserID).Single();
         // foreach role the user is being added to
         foreach (string role in roleNames)
         {
             UserRoleMapping mapping = new UserRoleMapping();
             mapping.UserID = userID;
             mapping.UserRoleID =
                 (from r in db.UserRoles
                  where r.RoleName.ToLower() == role.ToLower()
                  select r.RoleID).Single();
             db.UserRoleMappings.InsertOnSubmit(mapping);
         }
     }
     db.SubmitChanges();
 }
Example #2
0
 partial void DeleteUserRoleMapping(UserRoleMapping instance);
Example #3
0
 partial void UpdateUserRoleMapping(UserRoleMapping instance);
Example #4
0
 partial void InsertUserRoleMapping(UserRoleMapping instance);
Example #5
0
		private void detach_UserRoleMappings(UserRoleMapping entity)
		{
			this.SendPropertyChanging();
			entity.User = null;
		}
Example #6
0
		private void attach_UserRoleMappings(UserRoleMapping entity)
		{
			this.SendPropertyChanging();
			entity.UserRole = this;
		}