Example #1
0
        public override async Task <IList <User> > GetUsersInRoleAsync(string normalizedRoleName, CancellationToken cancellationToken = default(CancellationToken))
        {
            Role rol = await RoleManager.FindByNameAsync(normalizedRoleName);

            if (rol == null)
            {
                throw new DataException("No existe el rol con nombre :" + normalizedRoleName);
            }

            var usersId = AppUserRoleReadOnlyRepository.GetAll().Where(x => x.RoleId == rol.Id).Select(x => x.UserId).ToArray();

            var users = this.ReadOnlyRepository.GetAll().Where(x => usersId.Contains(x.Id));

            return(users.ToList());
        }
Example #2
0
        public override async Task <IList <string> > GetRolesAsync(User user, CancellationToken cancellationToken = default(CancellationToken))
        {
            var roles = AppUserRoleReadOnlyRepository.GetAll().Where(x => x.UserId == user.Id).Select(x => x.RoleId).ToArray();

            return(await Task.FromResult(RolesReadOnlyRepository.GetAll().Where(x => roles.Contains(x.Id)).Select(x => x.NormalizedName).ToList()));
        }