示例#1
0
        public ApplicationRole(RoleDto role)
        {
            Details = role;

            var roleType = (RoleTypeCodes)Enum.Parse(typeof(RoleTypeCodes), role.RoleType);

            _name = SecurityRoleNames.GetSecurityRoleName(RoleTypeCodes.SystemAdmin);
            if (_name == null)
            {
                throw new NotSupportedException($"{roleType} role name is not supported");
            }
        }
示例#2
0
        public Task <IList <string> > GetRolesAsync(ApplicationUser user)
        {
            IList <string> roleNames = _queryExecutor.Execute(context =>
            {
                long userId = user.Id;
                var types   = context
                              .Query <User>()
                              .Where(u => u.Id == userId)
                              .SelectMany(u => u.Roles)
                              .Select(r => r.RoleType)
                              .ToList()
                              .Distinct();

                return(types.Select(t => SecurityRoleNames.GetSecurityRoleName(t)).ToList());
            });

            return(Task.FromResult(roleNames));
        }