예제 #1
0
        public static RolesPermissions Load()
        {
            RolesPermissions rP        = new RolesPermissions();
            List <int>       AdminPerm = new List <int> {
                1, 3, 8
            };
            List <int> UserPerm = new List <int> {
                7
            };
            List <int> ClientPerm = new List <int> {
                2, 4, 5, 6
            };

            rP.rolPerm.Add(AdminPerm);
            rP.rolPerm.Add(UserPerm);
            rP.rolPerm.Add(ClientPerm);
            rP.NumOfRoles = 3;
            return(rP);
        }
예제 #2
0
 public static void AddRolesPermisons()
 {
     using (DataClassesDataContext dc = new DataClassesDataContext())
     {
         RolesPermissions rP = RolesPermissions.Load();
         for (int i = 0; i < rP.NumOfRoles; i++)
         {
             foreach (int j in rP.rolPerm[i])
             {
                 RolePermission rolesPermission = new RolePermission
                 {
                     RoleId       = i + 1,
                     PermissionId = j,
                 };
                 dc.RolePermissions.InsertOnSubmit(rolesPermission);
             }
         }
         dc.SubmitChanges();
     }
 }