using Application.Domain.Entities; using Infrastructure.Data; using Infrastructure.Web; using System.Collections.Generic; using System.Linq; namespace IoTNode { public class RoleService : IRoleService { private readonly IRepository _userRepo; public RoleService(IRepository userRepo) { this._userRepo = userRepo; } public List GetRoles(string userName) { var userPermissions = this._userRepo.ReadOnlyTable().Where(o => o.UserName == userName) .SelectMany(o => o.UserRoles) .Select(o => o.Role) .SelectMany(o => o.RolePermissions) .Select(o => o.Permission.Number) .ToList(); return userPermissions; } } }