public async Task <bool> CheckAsync(string permission) { long[] roleIds = CurrentUser.Roles; PermissionEntity permissionEntity = await _permissionRepo.Where(r => r.Name == permission).FirstAsync(); bool existPermission = await _rolePermissionRepo.Select .AnyAsync(r => roleIds.Contains(r.RoleId) && r.PermissionId == permissionEntity.Id); return(existPermission); }
public async Task <bool> CheckAsync(string permission, long userId) { var roleIds = await _userRoleRepo.Select.Where(ur => ur.UserId == userId).ToListAsync(ur => ur.RoleId); PermissionEntity permissionEntity = await _permissionRepo.Where(r => r.Name == permission).FirstAsync(); bool existPermission = await _rolePermissionRepo.Select .AnyAsync(r => roleIds.Contains(r.RoleId) && r.PermissionId == permissionEntity.Id); return(existPermission); }