private async Task <bool> HasPermissionAsync(long userId, PermissionGrantInfo permissionGrant) { return(await _userPermissionSettingRepository.FirstOrDefaultAsync( p => p.UserId == userId && p.Name == permissionGrant.Name && p.IsGranted == permissionGrant.IsGranted ) != null); }
private async Task RemovePermissionAsync(User user, PermissionGrantInfo permissionGrant) { await _userPermissionSettingRepository.DeleteAsync( permissionSetting => permissionSetting.UserId == user.Id && permissionSetting.Name == permissionGrant.Name && permissionSetting.IsGranted == permissionGrant.IsGranted ); }
private async Task RemovePermissionAsync(Role role, PermissionGrantInfo permissionGrant) { await _rolePermissionSettingRepository.DeleteAsync( permissionSetting => permissionSetting.RoleId == role.Id && permissionSetting.Name == permissionGrant.Name && permissionSetting.IsGranted == permissionGrant.IsGranted ); }
private async Task <bool> HasPermissionAsync(int roleId, PermissionGrantInfo permissionGrant) { return(await _rolePermissionSettingRepository.FirstOrDefaultAsync( p => p.RoleId == roleId && p.Name == permissionGrant.Name && p.IsGranted == permissionGrant.IsGranted ) != null); }
private async Task AddPermissionAsync(User user, PermissionGrantInfo permissionGrant) { if (await HasPermissionAsync(user.Id, permissionGrant)) { return; } await _userPermissionSettingRepository.InsertAsync( new UserPermissionSetting { TenantId = user.TenantId, UserId = user.Id, Name = permissionGrant.Name, IsGranted = permissionGrant.IsGranted }); }
private async Task AddPermissionAsync(Role role, PermissionGrantInfo permissionGrant) { if (await HasPermissionAsync(role.Id, permissionGrant)) { return; } await _rolePermissionSettingRepository.InsertAsync( new RolePermissionSetting { TenantId = role.TenantId, RoleId = role.Id, Name = permissionGrant.Name, IsGranted = permissionGrant.IsGranted }); }