예제 #1
0
 private void InsertGuestRoleAndAccess()
 {
     var guestRole = new RoleDb
     {
         CompanyId = Db.CompanyId,
         Type = (int)SystemRoles.Guest,
         Name = SystemRoles.Guest.GetDescription()
     };
     Db.SaveRole(guestRole);
     foreach (var componentId in Constants.ComponentsForGuest)
     {
         var componentsToRole = new ComponentsToRoleDb
         {
             CompanyId = Db.CompanyId,
             AccessLevel = (int)AccessLevel.Read,
             ComponentId = componentId,
             RoleId = guestRole.RoleId
         };
         Db.SaveComponentsToRole(componentsToRole);
     }
 }
예제 #2
0
 private int InsertAdminRoleAndAccess()
 {
     var adminRole = new RoleDb
                         {
                             CompanyId = Db.CompanyId,
                             Type = (int) SystemRoles.Administrator,
                             Name = SystemRoles.Administrator.GetDescription()
                         };
     Db.SaveRole(adminRole);
     foreach (var component in Enum.GetValues(typeof (AccessComponent)))
     {
         if((int)component == (int)AccessComponent.None)
             continue;
         var componentsToRole = new ComponentsToRoleDb
                                    {
                                        CompanyId = Db.CompanyId,
                                        AccessLevel = (int) AccessLevel.ReadWrite,
                                        ComponentId = (int) component,
                                        RoleId = adminRole.RoleId
                                    };
         Db.SaveComponentsToRole(componentsToRole);
     }
     return adminRole.RoleId;
 }