Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/12/12 17:22:59 (12 years ago)
Author:
ascheibe
Message:

#1648 added first version of an user information dialog

Location:
branches/ClientUserManagement/HeuristicLab.Services.Access/3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/AccessService.cs

    r7553 r7599  
    347347      DA.aspnet_User aspUser = null;
    348348      DA.User accessUser = null;
     349      List<DA.aspnet_Role> roles = new List<DA.aspnet_Role>();
     350      List<DA.UserGroup> groups = new List<DA.UserGroup>();
     351
    349352
    350353      using (DA.ASPNETAuthenticationDataContext context = new DA.ASPNETAuthenticationDataContext()) {
     
    354357        if (userQuery.Count() == 1) {
    355358          aspUser = userQuery.First();
     359          roles = (from ur in context.aspnet_UsersInRoles
     360                   where ur.UserId == aspUser.UserId
     361                   join r in context.aspnet_Roles on ur.RoleId equals r.RoleId
     362                   select r).ToList();
    356363        }
    357364      }
     
    364371          if (query.Count() == 1) {
    365372            accessUser = query.First();
     373            groups = (from ug in context.UserGroupUserGroups
     374                      where ug.UserGroupUserGroupId == accessUser.Id
     375                      join g in context.UserGroupBases.OfType<DA.UserGroup>() on ug.UserGroupId equals g.Id
     376                      select g).ToList();
    366377          } else {
    367378            //if the user is not in the access db add it (this makes it easy to upgrade with an existing asp.net authentication db)
     
    379390        throw new Exception("User with id " + userId + " not found.");
    380391      } else {
    381         return Convert.ToDto(accessUser, aspUser);
     392        return Convert.ToDto(accessUser, aspUser, roles, groups);
    382393      }
    383394    }
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/Convert.cs

    r7534 r7599  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Linq;
    2425using DA = HeuristicLab.Services.Access.DataAccess;
     
    286287    #region User
    287288
    288     public static DT.LightweightUser ToDto(DA.User source, DA.aspnet_User aspUserSource) {
     289    public static DT.LightweightUser ToDto(DA.User source, DA.aspnet_User aspUserSource, List<DA.aspnet_Role> roles, List<DA.UserGroup> groups) {
    289290      return new DT.LightweightUser() {
    290291        Id = source.Id,
    291292        FullName = source.FullName,
    292         UserName = aspUserSource.UserName
     293        UserName = aspUserSource.UserName,
     294        Roles = roles.Select(x => Convert.ToDto(x)).ToArray(),
     295        Groups = groups.Select(x => Convert.ToDto(x)).ToArray()
    293296      };
    294297    }
  • branches/ClientUserManagement/HeuristicLab.Services.Access/3.3/DataTransfer/LightweightUser.cs

    r7367 r7599  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Runtime.Serialization;
    2324
     
    2930    [DataMember]
    3031    public string FullName { get; set; }
     32    [DataMember]
     33    public IEnumerable<DataTransfer.Role> Roles { get; set; }
     34    [DataMember]
     35    public IEnumerable<DataTransfer.UserGroup> Groups { get; set; }
    3136  }
    3237}
Note: See TracChangeset for help on using the changeset viewer.