Пример #1
0
 /// <summary>
 /// 用户分配角色
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="roleIds"></param>
 public void UserAllotRoleByUserId(int userId, string[] roleIds)
 {
     using (DBContainer db = new DBContainer())
     {
         db.P_Sys_DeleteUserRole(userId);
         foreach (var roleId in roleIds)
         {
             if (!String.IsNullOrWhiteSpace(roleId))
             {
                 db.P_Sys_UserAllotRole(userId, Convert.ToInt32(roleId));
             }
         }
         db.SaveChanges();
     }
 }