Ignore:
Timestamp:
06/25/10 20:22:24 (9 years ago)
Author:
bfarka
Message:

added implementation of GetAllRoles in RoleProvider (#1046)

File:
1 edited

Legend:

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

    r3951 r3952  
    33using System.Linq;
    44using Persistence;
     5using System.Text;
     6using System.Collections.Generic;
    57
    68namespace Service.Provider {
     
    3234
    3335    public override string[] GetAllRoles() {
    34       throw new NotImplementedException();
     36      List<string> roleList = new List<string>();
     37
     38      List<HeuristicLabRole> roles = new List<HeuristicLabRole>(DatabaseUtil.createDataClassesDataContext().HeuristicLabRole.Select(r => r));
     39      foreach(HeuristicLabRole r in roles)
     40      {
     41        roleList.Add(r.RoleName);
     42      }
     43
     44      return roleList.ToArray();
    3545    }
    3646
    3747    public override string[] GetRolesForUser(string username) {
    38       throw new NotImplementedException();
     48      List<string> roleList = new List<string>();
     49      DataClassesDataContext context = DatabaseUtil.createDataClassesDataContext();
     50      if (username != null && context.HeuristicLabUsers.Count(u => u.UserName == username) > 0) {
     51       
     52        Persistence.HeuristicLabUser user = context.HeuristicLabUsers.Single(u => u.UserName == username);
     53        foreach (Persistence.HeuristicLabUserRole userRole in user.HeuristicLabUserRole) {
     54          roleList.Add(userRole.HeuristicLabRole.RoleName);
     55        }
     56      }
     57      context.Dispose();
     58      return roleList.ToArray();
    3959    }
    4060
Note: See TracChangeset for help on using the changeset viewer.