-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathPermissionManager.cs
38 lines (32 loc) · 1.19 KB
/
PermissionManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Collections.Generic;
using System.Threading.Tasks;
using Silky.Core.DependencyInjection;
using Silky.Identity.Application.Contracts.Role;
using Silky.Identity.Application.Contracts.User;
namespace Silky.Permission.Domain;
public class PermissionManager : IPermissionManager, IScopedDependency
{
private readonly IUserAppService _userAppService;
private readonly IRoleAppService _roleAppService;
public PermissionManager(IUserAppService userAppService,
IRoleAppService roleAppService)
{
_userAppService = userAppService;
_roleAppService = roleAppService;
}
public async Task<ICollection<string>> GetUserRoleNamesAsync(long userId)
{
var userRoleOutput = await _userAppService.GetRolesAsync(userId);
return userRoleOutput.RoleNames;
}
public async Task<ICollection<long>> GetUserRoleIdsAsync(long userId)
{
var userRoleIds = await _userAppService.GetRoleIdsAsync(userId);
return userRoleIds;
}
public async Task<ICollection<string>> GetRolePermissionsAsync(long roleId)
{
var rolePermissions = await _roleAppService.GetPermissionsAsync(roleId);
return rolePermissions;
}
}