Exemple #1
0
        public List <WebCommunityRoles> GetUserCommunityRoles(IfyContext context, UserTep entity)
        {
            context.LogDebug(this, "GetUserCommunityRoles");
            var communityroles = new List <WebCommunityRoles>();

            try {
                var communities = entity.GetUserCommunities();
                context.LogDebug(this, string.Format("GetUserCommunityRoles - found {0} communities", communities.Count));
                foreach (var community in communities)
                {
                    try {
                        var roles    = entity.GetUserRoles(community);
                        var webroles = new List <WebRole>();
                        foreach (var role in roles)
                        {
                            webroles.Add(new WebRole {
                                Description = role.Description,
                                Identifier  = role.Identifier,
                                Name        = role.Name
                            });
                        }
                        if (webroles.Count > 0)
                        {
                            communityroles.Add(new WebCommunityRoles {
                                Community           = community.Name,
                                CommunityIdentifier = community.Identifier,
                                Link  = string.Format("/#!communities/details/{0}", community.Identifier),
                                Roles = webroles
                            });
                        }
                    } catch (Exception e) {
                        context.LogError(this, e.Message, e);
                    }
                }
            } catch (Exception e) {
                context.LogError(this, e.Message, e);
            }
            context.LogDebug(this, string.Format("GetUserCommunityRoles - found {0} communitiesRoles", communityroles.Count));
            return(communityroles);
        }