Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/10 13:48:48 (14 years ago)
Author:
mholper
Message:

implemented last Method HeuristicLabRoleProvider.DeleteRole and UnitTest (#1046)
--> HeuristicLabRoleProvider finished now, all HeuristicLabRoleProviderTest passed (#1077)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs

    r3978 r4000  
    5454    }
    5555
     56    //
     57    // RoleProvider.DeleteRole
     58    //
    5659    public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) {
    57       throw new NotImplementedException();
     60      String[] roleArray = new String[1];
     61      roleArray[0] = roleName;
     62      Persistence.DataClassesDataContext db = DatabaseUtil.createDataClassesDataContext();
     63
     64      if (!RoleExists(roleName)) {
     65        return false;
     66        //throw new Exception("Role does not exist.");
     67      }
     68
     69      if (throwOnPopulatedRole && GetUsersInRole(roleName).Length > 0) {
     70        return false;
     71        //throw new ProviderException("Cannot delete a populated role.");
     72      }
     73
     74      RemoveUsersFromRoles(GetUsersInRole(roleName), roleArray);
     75
     76      Persistence.HeuristicLabRole role = db.HeuristicLabRole.Single(r => r.RoleName == roleName);
     77      db.HeuristicLabRole.DeleteOnSubmit(role);
     78      db.Dispose();
     79
     80      return true;
    5881    }
    5982
     
    107130        Persistence.HeuristicLabRole role = context.HeuristicLabRole.Single(r => r.RoleName == roleName);
    108131        foreach (Persistence.HeuristicLabUserRole roleUser in role.HeuristicLabUserRoles) {
    109           if(!userList.Contains(roleUser.HeuristicLabUser.UserName))
     132          if (!userList.Contains(roleUser.HeuristicLabUser.UserName))
    110133            userList.Add(roleUser.HeuristicLabUser.UserName);
    111134        }
     
    153176    }
    154177  }
    155 }
     178}//HeuristicLabRoleProvider
Note: See TracChangeset for help on using the changeset viewer.