You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
914 B
29 lines
914 B
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<User> _userRepo;
|
|
|
|
public RoleService(IRepository<User> userRepo)
|
|
{
|
|
this._userRepo = userRepo;
|
|
}
|
|
|
|
public List<string> 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;
|
|
}
|
|
}
|
|
} |